56 #error "Source file included in a project NOT based on the QXK kernel"
59Q_DEFINE_THIS_MODULE(
"qxk")
63#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
64#error qpc version 7.3.0 or higher required
85 if (ceiling > QXK_priv_.lockCeil) {
89 QS_2U8_PRE_((uint8_t)QXK_priv_.lockCeil, (uint8_t)ceiling);
97 QXK_priv_.lockHolder = (QXK_priv_.curr != (
QActive *)0)
98 ? (uint_fast8_t)QXK_priv_.curr->prio
100 QXK_priv_.lockCeil = ceiling;
116 uint8_t
const prevCeil = (uint8_t)(stat >> 8U);
127 QS_2U8_PRE_((uint8_t)QXK_priv_.lockCeil, (uint8_t)prevCeil);
131 QXK_priv_.lockCeil = prevCeil;
132 QXK_priv_.lockHolder = (stat & 0xFFU);
135 if (QXK_sched_() != 0U) {
153 struct QActive *curr = QXK_priv_.curr;
168uint_fast8_t QXK_sched_(
void) {
170 &QXK_priv_.readySet_dis));
172 QActive const *
const curr = QXK_priv_.curr;
174 if (QPSet_isEmpty(&QXK_priv_.readySet)) {
179 p = QPSet_findMax(&QXK_priv_.readySet);
180 if (p <= QXK_priv_.lockCeil) {
184 QPSet_hasElement(&QXK_priv_.readySet, p));
194 if (p > QXK_priv_.actPrio) {
195 QXK_priv_.next = next;
210 QXK_priv_.next = next;
223void QXK_activate_(
void) {
224 uint_fast8_t
const prio_in = QXK_priv_.actPrio;
225 QActive *next = QXK_priv_.next;
231 #if (defined QF_ON_CONTEXT_SW) || (defined Q_SPY)
232 QXK_contextSw_(next);
239 uint_fast8_t p = (uint_fast8_t)next->
prio;
243 QXK_priv_.actPrio = p;
252 #if (QF_MAX_EPOOL > 0U)
261 &QXK_priv_.readySet_dis));
264 QPSet_remove(&QXK_priv_.readySet, p);
266 QPSet_update_(&QXK_priv_.readySet, &QXK_priv_.readySet_dis);
270 if (QPSet_isEmpty(&QXK_priv_.readySet)) {
277 p = (uint8_t)QPSet_findMax(&QXK_priv_.readySet);
278 if (p <= QXK_priv_.lockCeil) {
279 p = QXK_priv_.lockHolder;
282 QPSet_hasElement(&QXK_priv_.readySet, p));
294 #if (defined QF_ON_CONTEXT_SW) || (defined Q_SPY)
295 if (p != QXK_priv_.actPrio) {
296 QXK_contextSw_(next);
299 QXK_priv_.next = next;
307 QXK_priv_.next = next;
315 QXK_priv_.actPrio = prio_in;
317 #if (defined QF_ON_CONTEXT_SW) || (defined Q_SPY)
319 QXK_contextSw_((prio_in == 0U)
330 uint8_t
const prev_prio = (QXK_priv_.prev != (
QActive *)0)
331 ? QXK_priv_.prev->prio
336 QS_2U8_PRE_(next->
prio, prev_prio);
342 QS_U8_PRE_(prev_prio);
347 #ifdef QF_ON_CONTEXT_SW
348 QF_onContextSw(QXK_priv_.prev, next);
351 QXK_priv_.prev = next;
356void QXK_threadExit_(
void) {
365 QXK_priv_.lockHolder != (uint_fast8_t)thr->
super.
prio);
367 uint_fast8_t
const p = (uint_fast8_t)thr->
super.
prio;
371 QPSet_remove(&QXK_priv_.readySet, p);
373 QPSet_update_(&QXK_priv_.readySet, &QXK_priv_.readySet_dis);
389 QF_bzero_(&QXK_priv_,
sizeof(QXK_priv_));
396 QPSet_update_(&QXK_priv_.readySet, &QXK_priv_.readySet_dis);
399 for (uint_fast8_t tickRate = 0U;
400 tickRate <
Q_DIM(QTimeEvt_timeEvtHead_);
403 QTimeEvt_ctorX(&QTimeEvt_timeEvtHead_[tickRate],
451 QXK_priv_.lockCeil = 0U;
454 if (QXK_sched_() != 0U) {
477void QActive_start_(
QActive *
const me,
479 QEvt const * *
const qSto,
480 uint_fast16_t
const qLen,
482 uint_fast16_t
const stkSize,
483 void const *
const par)
488 && ((prioSpec & 0xFF00U) == 0U));
491 me->
prio = (uint8_t)(prioSpec & 0xFFU);
493 QActive_register_(me);
495 if (stkSto == (
void *)0) {
497 QEQueue_init(&me->
eQueue, qSto, qLen);
508 if (QXK_sched_() != 0U) {
518 if (qSto != (
QEvt const **)0) {
519 QEQueue_init(&me->
eQueue, qSto, qLen);
524 QXThread_stackInit_(me, me->
super.
temp.
thr, stkSto, stkSize);
533 QPSet_insert(&QXK_priv_.readySet, (uint_fast8_t)me->
prio);
535 QPSet_update_(&QXK_priv_.readySet, &QXK_priv_.readySet_dis);
QActive * QActive_registry_[QF_MAX_ACTIVE+1U]
uint_fast8_t QSchedStatus
@ Q_USER_SIG
offset for the user signals (QP Application)
Internal (package scope) QP/C interface.
#define QACTIVE_CAST_(ptr_)
#define QXK_ISR_CONTEXT_()
Check if the code executes in the ISR context.
#define QXK_CONTEXT_SWITCH_()
Trigger context switch (used internally in QXK only)
#define QF_INT_DISABLE()
Disable interrupts.
#define QF_INT_ENABLE()
Enable interrupts.
@ QS_QF_RUN
QF_run() was entered.
@ QS_SCHED_IDLE
scheduler restored the idle task
#define QS_SIG_DICTIONARY(sig_, obj_)
@ QS_SCHED_LOCK
scheduler was locked
@ QS_SCHED_UNLOCK
scheduler was unlocked
@ QS_SCHED_NEXT
scheduler started next task
QS/C package-scope interface.
QP Functional Safety (FuSa) Subsystem.
#define Q_ASSERT_INCRIT(id_, expr_)
#define Q_REQUIRE_INCRIT(id_, expr_)
uint_fast16_t QSchedStatus
#define QXTHREAD_CAST_(ptr_)
Active object class (based on the QHsm implementation strategy)
QACTIVE_OS_OBJ_TYPE osObject
QACTIVE_EQUEUE_TYPE eQueue
QEvt const * QActive_get_(QActive *const me)
struct QAsmVtable const * vptr
Virtual table for the QAsm class.
void(* init)(QAsm *const me, void const *const e, uint_fast8_t const qsId)
void(* dispatch)(QAsm *const me, QEvt const *const e, uint_fast8_t const qsId)
State object for the QMsm class (QM State Machine).
Private attributes of the QXK kernel.
eXtended (blocking) thread of the QXK preemptive kernel
struct QMState const * obj