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

QK preemptive non-blocking kernel. More...

#include <qk.hpp>

Static Public Member Functions

static QSchedStatus schedLock (std::uint8_t const ceiling) noexcept
 QK selective scheduler lock.
static void schedUnlock (QSchedStatus const prevCeil) noexcept
 QK selective scheduler unlock.
static void onIdle ()
 QK idle callback (customized in BSPs for QK).
static std::uint_fast8_t sched_ () noexcept
 QK scheduler finds the highest-priority AO ready to run.
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 activate_ ()
 QK activator activates the next active object. The activated AO preempts the currently executing AOs.

Public Attributes

QP::QPSet readySet
 Set of active-objects/threads that are ready to run in the QK kernel.
std::uint8_t actPrio
 Priority of the currently active AO.
std::uint8_t nextPrio
 Next AO priority scheduled by QK.
std::uint8_t actThre
 Preemption threshold of the currently active AO.
std::uint8_t lockCeil
 Scheduler lock-ceiling (0 if scheduler unlocked).
std::uint8_t intNest
 Up-down counter indicating current interrupt nesting (used in some QK ports).

Static Public Attributes

static QK priv_

Detailed Description

QK preemptive non-blocking kernel.

See also
Preemptive Non-Blocking Kernel

Definition at line 38 of file qk.hpp.

Member Function Documentation

◆ schedLock()

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

QK selective scheduler lock.

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

Parameters
[in]ceilingpreemption ceiling to which the QK scheduler needs to be locked
Returns
The previous QK Scheduler lock status, which is to be used to unlock the scheduler by restoring its previous lock status in QK::schedUnlock().
Note
QK::schedLock() must be always followed by the corresponding QK_schedUnlock().
See also
QK_schedUnlock()

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

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

Definition at line 56 of file qk.cpp.

◆ schedUnlock()

void QP::QK::schedUnlock ( QSchedStatus const prevCeil)
staticnoexcept

QK selective scheduler unlock.

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

Parameters
[in]prevCeilprevious QK Scheduler lock ceiling returned from QK::schedLock()
Note
QK::schedUnlock() must always follow the corresponding QK::schedLock().
See also
QK::schedLock()

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

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

Definition at line 83 of file qk.cpp.

◆ onIdle()

void QP::QK::onIdle ( )
static

QK idle callback (customized in BSPs for QK).

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

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

◆ sched_()

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

QK scheduler finds the highest-priority AO ready to run.

Details
The QK scheduler finds out the priority of the highest-priority AO that (1) has events to process and (2) has priority that is above the current priority.

Returns
The QF-priority of the next Active Object to activate, or zero if no activation of AO is needed.
Attention
QK::sched_() must be always called with interrupts disabled and returns with interrupts disabled.

Definition at line 115 of file qk.cpp.

◆ sched_act_()

std::uint_fast8_t QP::QK::sched_act_ ( QActive const *const act,
std::uint_fast8_t const pthre_in )
staticnoexcept

QK internal helper function to determine whether activation is needed.

Details

Parameters
[in]actcurrently executing Active Object
[in]pthre_incurrent priority threshold
Returns
the priority of Active Object to activate or 0 if no activation needed
Attention
QK::act_() must be always called with interrupts disabled and returns with interrupts disabled.

Definition at line 142 of file qk.cpp.

◆ activate_()

void QP::QK::activate_ ( )
static

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

Details
QK::activate_() activates ready-to run AOs that are above the initial preemption-threshold.

Attention
QK::activate_() must be always called with interrupts disabled and returns with interrupts disabled.

Definition at line 177 of file qk.cpp.

Member Data Documentation

◆ readySet

QP::QPSet QP::QK::readySet

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

Definition at line 40 of file qk.hpp.

◆ actPrio

std::uint8_t QP::QK::actPrio

Priority of the currently active AO.

Definition at line 41 of file qk.hpp.

◆ nextPrio

std::uint8_t QP::QK::nextPrio

Next AO priority scheduled by QK.

Definition at line 42 of file qk.hpp.

◆ actThre

std::uint8_t QP::QK::actThre

Preemption threshold of the currently active AO.

Definition at line 43 of file qk.hpp.

◆ lockCeil

std::uint8_t QP::QK::lockCeil

Scheduler lock-ceiling (0 if scheduler unlocked).

Definition at line 44 of file qk.hpp.

◆ intNest

std::uint8_t QP::QK::intNest

Up-down counter indicating current interrupt nesting (used in some QK ports).

Definition at line 45 of file qk.hpp.

◆ priv_

QK QP::QK::priv_
static

Definition at line 58 of file qk.hpp.


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