QP/C++ 8.1.2
Real-Time Event Framework
Loading...
Searching...
No Matches

QXK dual-mode (non-blocking / blocking) kernel. More...

#include <qxk.hpp>

Static Public Member Functions

static QSchedStatus schedLock (std::uint8_t const ceiling) noexcept
 QXK Scheduler lock.
static void schedUnlock (QSchedStatus const stat) noexcept
 QXK Scheduler unlock.
static void onIdle ()
 QXK idle callback (customized in BSPs for QXK).
static QActivecurrent () noexcept
static std::uint_fast8_t sched_ () noexcept
 QXK scheduler finds the highest-priority thread ready to run.
static void threadExit_ () noexcept
 Called when QP::QXThread exits.
static void activate_ ()
 QXK activator activates the next active object. The activated AO preempts the currently executing AOs.
static QMStateqmstate_cast_ (void *ptr)

Public Attributes

QActivecurr
QActivenext
QActiveprev
std::uint8_t actPrio
std::uint8_t lockCeil
std::uint8_t lockHolder
std::uint8_t intNest
QPSet readySet
 Set of active-objects/threads that are ready to run in the QXK kernel.

Static Public Attributes

static constexpr QSignal DELAY_SIG { 1 }
static constexpr QSignal TIMEOUT_SIG { 2 }

Detailed Description

QXK dual-mode (non-blocking / blocking) kernel.

See also
Preemptive Dual-Mode Kernel The QXK class is related to the following classes:

Definition at line 40 of file qxk.hpp.

Member Function Documentation

◆ schedLock()

QSchedStatus QP::QXK::schedLock ( std::uint8_t const ceiling)
staticnoexcept

QXK Scheduler lock.

Details
This function locks the QXK scheduler to the specified ceiling.

Parameters
[in]ceilingpreemption ceiling to which the QXK scheduler needs to be locked
Returns
The previous QXK Scheduler lock status, which is to be used to unlock the scheduler by restoring its previous lock status in QXK_schedUnlock().
Note
A QXK scheduler can be locked from both basic threads (AOs) and extended threads and the scheduler locks can nest.
QXK::schedLock() must be always followed by the corresponding QXK::schedUnlock().
Attention
QXK will fire an assertion if a thread holding the lock attempts to block.
See also
QXK::schedUnlock()

Usage
The following example shows how to lock and unlock the QXK scheduler:

std::uint32_t BSP::random() {
QP::QSchedStatus lockStat = QP::QXK::schedLock(N_PHILO); // <== lock
std::uint32_rnd = ...
. . . // access/manipulate the shared random seed resource
return rnd;
}
static QSchedStatus schedLock(std::uint8_t const ceiling) noexcept
QXK Scheduler lock.
Definition qxk.cpp:53
static void schedUnlock(QSchedStatus const stat) noexcept
QXK Scheduler unlock.
Definition qxk.cpp:87
std::uint8_t QSchedStatus
The scheduler lock status for QK::schedLock() and QK::schedUnlock().
Definition qk.hpp:35

Definition at line 53 of file qxk.cpp.

◆ schedUnlock()

void QP::QXK::schedUnlock ( QSchedStatus const stat)
staticnoexcept

QXK Scheduler unlock.

Details
This function unlocks the QXK scheduler to the previous status.

Parameters
[in]statprevious QXK Scheduler lock status returned from QXK_schedLock()
Note
A QXK scheduler can be locked from both basic threads (AOs) and extended threads and the scheduler locks can nest.
QXK::schedUnlock() must always follow the corresponding QXK::schedLock().

Usage
The following example shows how to lock and unlock the QXK scheduler:

std::uint32_t BSP::random() {
QP::QSchedStatus lockStat = QP::QXK::schedLock(N_PHILO);
std::uint32_rnd = ...
. . . // access/manipulate the shared random seed resource
QP::QXK::schedUnlock(lockStat); // <== unlock
return rnd;
}

Definition at line 87 of file qxk.cpp.

◆ onIdle()

void QP::QXK::onIdle ( )
static

QXK idle callback (customized in BSPs for QXK).

Details
QXK::onIdle() is called continuously by the QXK idle thread. This callback gives the application an opportunity to enter a power-saving CPU mode, or perform some other idle processing.

Note
QXK::onIdle() is invoked with interrupts enabled and must also return with interrupts enabled.

◆ current()

QActive * QP::QXK::current ( )
staticnoexcept

Definition at line 121 of file qxk.cpp.

◆ sched_()

std::uint_fast8_t QP::QXK::sched_ ( )
staticnoexcept

QXK scheduler finds the highest-priority thread ready to run.

Details
The QXK scheduler finds the priority of the highest-priority thread that is ready to run.

Returns
the 1-based priority of the the thread (basic or extended) run next, or zero if no eligible thread is found.
Attention
QXK::sched_() must be always called with interrupts disabled and returns with interrupts disabled. QXK::sched_() is defined with the "C" linkage (extern "C").

Definition at line 174 of file qxk.cpp.

◆ threadExit_()

void QP::QXK::threadExit_ ( )
staticnoexcept

Called when QP::QXThread exits.

Details
Called when the extended-thread handler function returns.

Note
Most thread handler functions are structured as endless loops that never return. But it is also possible to structure threads as one-shot functions that perform their job and return. In that case this function performs cleanup after the thread.

Definition at line 326 of file qxk.cpp.

◆ activate_()

void QP::QXK::activate_ ( )
static

QXK activator activates the next active object. The activated AO preempts the currently executing AOs.

Details
QXK::activate_() activates ready-to run AOs that are above the initial active priority (QXK_priv_.actPrio).

Attention
QXK::activate_() must be always called with interrupts disabled and returns with interrupts disabled. QXK::activate_() is defined with the "C" linkage (extern "C").

Definition at line 222 of file qxk.cpp.

◆ qmstate_cast_()

QMState * QP::QXK::qmstate_cast_ ( void * ptr)
inlinestatic

Definition at line 66 of file qxk.hpp.

Member Data Documentation

◆ curr

QActive* QP::QXK::curr

Definition at line 44 of file qxk.hpp.

◆ next

QActive* QP::QXK::next

Definition at line 45 of file qxk.hpp.

◆ prev

QActive* QP::QXK::prev

Definition at line 46 of file qxk.hpp.

◆ actPrio

std::uint8_t QP::QXK::actPrio

Definition at line 47 of file qxk.hpp.

◆ lockCeil

std::uint8_t QP::QXK::lockCeil

Definition at line 48 of file qxk.hpp.

◆ lockHolder

std::uint8_t QP::QXK::lockHolder

Definition at line 49 of file qxk.hpp.

◆ intNest

std::uint8_t QP::QXK::intNest

Definition at line 50 of file qxk.hpp.

◆ readySet

QPSet QP::QXK::readySet

Set of active-objects/threads that are ready to run in the QXK kernel.

Definition at line 51 of file qxk.hpp.

◆ DELAY_SIG

QSignal QP::QXK::DELAY_SIG { 1 }
staticconstexpr

Definition at line 63 of file qxk.hpp.

◆ TIMEOUT_SIG

QSignal QP::QXK::TIMEOUT_SIG { 2 }
staticconstexpr

Definition at line 64 of file qxk.hpp.


The documentation for this class was generated from the following files: