37 #include "qs_port.hpp"
40 #include "qs_dummy.hpp"
45 #error "Source file included in a project NOT based on the QXK kernel"
54class QXKIdleThread : public
QP::QActive {
56 QXKIdleThread() :
QP::QActive(nullptr)
60static QXKIdleThread l_idleThread;
83 bzero(&l_idleThread,
sizeof(l_idleThread));
140 QEvt
const * *
const qSto, std::uint_fast16_t
const qLen,
141 void *
const stkSto, std::uint_fast16_t
const stkSize,
142 void const *
const par)
151 && (stkSto ==
nullptr)
154 m_eQueue.init(qSto, qLen);
155 m_osObject =
nullptr;
156 m_prio =
static_cast<std::uint8_t
>(prio);
157 m_dynPrio =
static_cast<std::uint8_t
>(prio);
211 std::uint_fast8_t
const lockPrio
213 std::uint_fast8_t
const prevPrio
214 =
static_cast<std::uint_fast8_t
>(stat >> 8U);
222 && (lockPrio > prevPrio));
257 p =
static_cast<std::uint_fast8_t
>(
273 if (next->m_osObject ==
nullptr) {
320 std::uint_fast8_t
const pin =
325#if (defined QXK_ON_CONTEXT_SW) || (defined Q_SPY)
326 std::uint_fast8_t pprev = pin;
333 std::uint_fast8_t p =
static_cast<std::uint_fast8_t
>(a->m_dynPrio);
348#if (defined QXK_ON_CONTEXT_SW) || (defined Q_SPY)
351#ifdef QXK_ON_CONTEXT_SW
377 if (a->m_eQueue.isEmpty()) {
399 if (a->m_osObject ==
nullptr) {
424#if (defined QXK_ON_CONTEXT_SW) || (defined Q_SPY)
442#ifdef QXK_ON_CONTEXT_SW
459 if (curr ==
nullptr) {
QActive active object class (based on QP::QHsm implementation strategy)
std::uint8_t m_prio
QF priority (1..QF_MAX_ACTIVE) of this active object.
virtual void start(std::uint_fast8_t const prio, QEvt const **const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize, void const *const par)
Starts execution of an active object and registers the object with the framework.
QEvt const * get_(void) noexcept
Get an event from the event queue of an active object.
static void onStartup(void)
Startup QF callback.
static void init(void)
QF initialization.
static void onCleanup(void)
Cleanup QF callback.
static int_t run(void)
Transfers control to QF to run the application.
static QTimeEvt timeEvtHead_[QF_MAX_TICK_RATE]
heads of linked lists of time events, one for every clock tick rate
static void gc(QEvt const *const e) noexcept
Recycle a dynamic event.
static void bzero(void *const start, std::uint_fast16_t const len) noexcept
Clear a specified region of memory to zero.
static void add_(QActive *const a) noexcept
Register an active object to be managed by the framework.
static void stop(void)
Function invoked by the application layer to stop the QF application and return control to the OS/Ker...
static QActive * active_[QF_MAX_ACTIVE+1U]
Internal array of registered active objects.
virtual void dispatch(QEvt const *const e, std::uint_fast8_t const qs_id)
Dispatches an event to QHsm.
virtual void init(void const *const e, std::uint_fast8_t const qs_id)
executes the top-most initial transition in QP::QHsm
static QSchedStatus schedLock(std::uint_fast8_t const ceiling) noexcept
QXK selective scheduler lock.
static void schedUnlock(QSchedStatus const stat) noexcept
QXK selective scheduler unlock.
static void onIdle(void)
QXK idle callback (customized in BSPs for QXK)
namespace associated with the QP/C++ framework
@ QS_QF_RUN
QF_run() was entered.
@ QS_SCHED_IDLE
scheduler became idle
@ QS_SCHED_LOCK
scheduler was locked
@ QS_SCHED_UNLOCK
scheduler was unlocked
@ QS_SCHED_NEXT
scheduler found next task to execute
@ QS_SCHED_RESUME
scheduler resumed previous task (not idle)
enum_t QF_maxPubSignal_
the maximum published signal
std::uint_fast8_t QF_maxPool_
static void initial_events(void)
process all events posted during initialization
std::uint_fast16_t QSchedStatus
The scheduler lock status.
QSubscrList * QF_subscrList_
the subscriber list array
Customizable and memory-efficient assertions for embedded systems.
#define Q_DEFINE_THIS_MODULE(name_)
#define Q_ASSERT_ID(id_, test_)
#define Q_ENSURE_ID(id_, test_)
#define Q_REQUIRE_ID(id_, test_)
int int_t
alias for line numbers in assertions and return from QF::run()
#define QF_CRIT_STAT_
This is an internal macro for defining the critical section status type.
#define QF_CRIT_X_()
This is an internal macro for exiting a critical section.
#define QF_CRIT_E_()
This is an internal macro for entering a critical section.
#define QS_TIME_PRE_()
Internal macro to output time stamp to a QS record.
#define QS_FLUSH()
Flush the QS trace data to the host.
Internal (package scope) QS/C++ interface.
#define QS_U8_PRE_(data_)
Internal QS macro to output an unformatted uint8_t data element.
#define QS_BEGIN_NOCRIT_PRE_(rec_, qs_id_)
Internal QS macro to begin a predefined QS record without critical section.
#define QS_END_NOCRIT_PRE_()
Internal QS macro to end a predefiend QS record without critical section.
#define QS_2U8_PRE_(data1_, data2_)
Internal QS macro to output 2 unformatted uint8_t data elements.
void QXK_activate_(void)
QXK activator activates the next active object.
std::uint_fast8_t QXK_sched_(void) noexcept
QXK scheduler finds the highest-priority thread ready to run.
QXK_Attr QXK_attr_
global attributes of the QXK kernel
QP::QActive * QXK_current(void) noexcept
return the currently executing active-object/thread
std::uint8_t volatile lockPrio
lock prio (0 == no-lock)
std::uint8_t volatile lockHolder
prio of the lock holder
void QXK_onContextSw(QP::QActive *prev, QP::QActive *next)
QXK context switch callback (customized in BSPs for QXK)
#define QXK_ISR_CONTEXT_()
Internal port-specific macro that reports the execution context.
QP::QActive * idleThread
pointer to the idle thread
QP::QActive *volatile next
next thread to execute
std::uint8_t volatile actPrio
prio of the active basic thread
QP::QPSet readySet
ready-set of all threads
QP::QActive *volatile curr
currently executing thread
attributes of the QXK kernel
Internal (package scope) QXK/C++ interface.
#define QXK_CONTEXT_SWITCH_()
bool hasElement(std::uint_fast8_t const n) const noexcept
the function evaluates to TRUE if the priority set has the element n.
void rmove(std::uint_fast8_t const n) noexcept
remove element n from the set, n = 1..64
std::uint_fast8_t findMax(void) const noexcept
find the maximum element in the set, returns zero if the set is empty