37 #include "qs_dummy.hpp"
42 #error Source file included in a project NOT based on the QK kernel
47Q_DEFINE_THIS_MODULE(
"qk")
73 if (ceiling >
priv_.lockCeil) {
84 priv_.lockCeil =
static_cast<std::uint8_t
>(ceiling);
94 if (prevCeil != 0xFFU) {
108 static_cast<std::uint8_t
>(prevCeil));
112 priv_.lockCeil = prevCeil;
128 if (
priv_.readySet.notEmpty()) {
130 p =
static_cast<std::uint8_t
>(
priv_.readySet.findMax());
133 if (p <=
priv_.actThre) {
138 if (p <=
priv_.lockCeil) {
153 std::uint_fast8_t
const pthre_in)
noexcept
157 std::uint8_t p = act->m_prio;
158 if (act->m_eQueue.isEmpty()) {
159 priv_.readySet.remove(p);
162 if (
priv_.readySet.isEmpty()) {
167 p =
static_cast<std::uint8_t
>(
priv_.readySet.findMax());
176 if (p <=
priv_.lockCeil) {
189 std::uint8_t
const prio_in =
priv_.actPrio;
190 std::uint8_t p =
priv_.nextPrio;
199#if (defined QF_ON_CONTEXT_SW) || (defined Q_SPY)
200 std::uint8_t pprev = prio_in;
205 std::uint8_t pthre_in = 0U;
221 std::uint8_t
const pthre = a->
m_pthre;
225 priv_.actThre = pthre;
227#if (defined QF_ON_CONTEXT_SW) || (defined Q_SPY)
235#ifdef QF_ON_CONTEXT_SW
247#if (QF_MAX_EPOOL > 0U)
255 p =
static_cast<std::uint8_t
>(
sched_act_(a, pthre_in));
260 priv_.actPrio = prio_in;
261 priv_.actThre = pthre_in;
263#if (defined QF_ON_CONTEXT_SW) || (defined Q_SPY)
271#ifdef QF_ON_CONTEXT_SW
282#ifdef QF_ON_CONTEXT_SW
312 QS::beginRec_(
static_cast<std::uint_fast8_t
>(
QS_QF_RUN));
322#ifdef QF_ON_CONTEXT_SW
347 std::uint_fast16_t
const qLen,
349 std::uint_fast16_t
const stkSize,
350 void const *
const par)
363 m_prio =
static_cast<std::uint8_t
>(prioSpec & 0xFFU);
364 m_pthre =
static_cast<std::uint8_t
>(prioSpec >> 8U);
Active object class (based on the QP::QHsm implementation strategy).
void register_() noexcept
Register this active object to be managed by the framework.
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
QACTIVE_EQUEUE_TYPE m_eQueue
Port-dependent event-queue type (often QP::QEQueue).
QEvt const * get_() noexcept
Get an event from the event queue of an active object.
void start(QPrioSpec const prioSpec, QEvtPtr *const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize, void const *const par=nullptr)
Starts execution of an active object and registers the object with the framework.
std::uint8_t m_pthre
Preemption-threshold [1..QF_MAX_ACTIVE] of this AO.
std::uint8_t m_prio
QF-priority [1..QF_MAX_ACTIVE] of this AO.
QK preemptive non-blocking kernel.
std::uint8_t intNest
Up-down counter indicating current interrupt nesting (used in some QK ports).
static std::uint_fast8_t sched_act_(QActive const *const act, std::uint_fast8_t const pthre_in) noexcept
QK internal helper function to determine whether activation is needed.
static void schedUnlock(QSchedStatus const prevCeil) noexcept
QK selective scheduler unlock.
QP::QPSet readySet
Set of active-objects/threads that are ready to run in the QK kernel.
std::uint8_t lockCeil
Scheduler lock-ceiling (0 if scheduler unlocked).
static std::uint_fast8_t sched_() noexcept
QK scheduler finds the highest-priority AO ready to run.
std::uint8_t actPrio
Priority of the currently active AO.
static QSchedStatus schedLock(std::uint8_t const ceiling) noexcept
QK selective scheduler lock.
std::uint8_t nextPrio
Next AO priority scheduled by QK.
static void activate_()
QK activator activates the next active object. The activated AO preempts the currently executing AOs.
static void onIdle()
QK idle callback (customized in BSPs for QK).
std::uint8_t actThre
Preemption threshold of the currently active AO.
QF Active Object Framework namespace.
void onCleanup()
Cleanup QF callback.
void gc(QEvt const *const e) noexcept
Recycle a mutable (mutable) event.
void init()
QF initialization.
int_t run()
Transfers control to QF to run the application.
void stop()
Invoked by the application layer to stop the QF framework and return control to the OS/Kernel (used i...
void onStartup()
Startup QF callback.
QP/C++ Framework namespace.
@ QS_SCHED_LOCK
scheduler was locked
@ QS_QF_RUN
QF_run() was entered.
@ QS_SCHED_NEXT
scheduler started next task
@ QS_SCHED_UNLOCK
scheduler was unlocked
@ QS_SCHED_IDLE
scheduler restored the idle task
std::array< QActive *, QF_MAX_ACTIVE+1U > QActive_registry_
Internal array of pointers to the registered Active Objects.
std::uint16_t QPrioSpec
Priority specification for Active Objects in QP.
std::uint8_t QSchedStatus
The scheduler lock status for QK::schedLock() and QK::schedUnlock().
int int_t
Alias for assertion-ID numbers in QP assertions and return from QP::QF::run().
#define Q_UNUSED_PAR(par_)
Helper macro to mark unused parameters of functions.
void QF_onContextSw(QP::QActive *prev, QP::QActive *next)
#define QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64).
QP/C++ Framework in C++ internal (package-scope) interface.
#define QK_ISR_CONTEXT_()
Port-specific method to check if the QK kernel executes in the ISR context (used internally in QK onl...
#define QF_INT_DISABLE()
Port-specific interrupt disable.
#define QF_INT_ENABLE()
Port-specific interrupt enable.
QS (QP/Spy software tracing) internal (package-scope) interface.
#define QS_2U8_PRE(data1_, data2_)
Output two pre-formatted unsigned 8-bit integer data elements.
#define QS_U8_PRE(data_)
Output pre-formatted unsigned 8-bit integer data element.
#define QS_END_PRE()
Pre-formatted QS trace record end.
#define QS_BEGIN_PRE(rec_, qsId_)
Pre-formatted QS trace record begin.
QP Functional Safety (FuSa) Subsystem.
#define Q_ASSERT_INCRIT(id_, expr_)
General-purpose assertion with user-specified ID number (in critical section).
#define Q_REQUIRE_INCRIT(id_, expr_)
Assertion for checking a precondition (in critical section).