QP/C++  6.9.3
Real-Time Embedded Framework
QK Class Reference

#include <qk.hpp>

Collaboration diagram for QK:
Collaboration graph

Static Public Member Functions

static QSchedStatus schedLock (std::uint_fast8_t const ceiling) noexcept
 QK selective scheduler lock. More...
 
static void schedUnlock (QSchedStatus const stat) noexcept
 QK selective scheduler unlock. More...
 
static void onIdle (void)
 
static char_t const * getVersion (void) noexcept
 get the current QK version number string of the form X.Y.Z More...
 

Detailed Description

QK services.

Description
This class groups together QK services. It has only static members and should not be instantiated.
Note
The QK scheduler, QK priority, QK ready set, etc. belong conceptually to the QK class (as static class members). However, to avoid potential C++ name-mangling problems in assembly language, these elements are defined outside of the QK class and use the extern "C" linkage.

Definition at line 132 of file qk.hpp.

Member Function Documentation

◆ schedLock()

QSchedStatus schedLock ( std::uint_fast8_t const  ceiling)
staticnoexcept

QK selective scheduler lock.

Description
This function locks the QK scheduler to the specified ceiling.
Parameters
[in]ceilingpriority 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 QP::QK::schedUnlock().
Note
QP::QK::schedLock() must be always followed by the corresponding QP::QK::schedUnlock().
See also
QK_schedUnlock()
Usage
The following example shows how to lock and unlock the QK scheduler:
std::uint32_t BSP::random(void) {
// lock the scheduler around l_rnd up to the (N_PHILO + 1U) ceiling
QP::QSchedStatus lockStat = QP::QK::schedLock(N_PHILO + 1U);
// "Super-Duper" Linear Congruential Generator (LCG)
// LCG(2^32, 3*7*11*13*23, 0, seed)
//
uint32_t rnd = l_rnd * (3U*7U*11U*13U*23U);
l_rnd = rnd; // set for the next time
QP::QK::schedUnlock(lockStat); // unlock sched after accessing l_rnd
return (rnd >> 8);
}
unsigned long int uint32_t
Definition: 16bit/stdint.h:31
static QSchedStatus schedLock(std::uint_fast8_t const ceiling) noexcept
QK selective scheduler lock.
Definition: qk.cpp:227
static void schedUnlock(QSchedStatus const stat) noexcept
QK selective scheduler unlock.
Definition: qk.cpp:277
std::uint_fast16_t QSchedStatus
The scheduler lock status.
Definition: qk.hpp:119
Precondition
The QK scheduler lock:
  • cannot be called from an ISR;

Definition at line 227 of file qk.cpp.

◆ schedUnlock()

void schedUnlock ( QSchedStatus const  stat)
staticnoexcept

QK selective scheduler unlock.

Description
This function unlocks the QK scheduler to the previous status.
Parameters
[in]statprevious QK Scheduler lock status returned from QP::QK::schedLock()
Note
QP::QK::schedUnlock() must always follow the corresponding QP::QK::schedLock().
See also
QP::QK::schedLock()
Usage
The following example shows how to lock and unlock the QK scheduler:
std::uint32_t BSP::random(void) {
// lock the scheduler around l_rnd up to the (N_PHILO + 1U) ceiling
QP::QSchedStatus lockStat = QP::QK::schedLock(N_PHILO + 1U);
// "Super-Duper" Linear Congruential Generator (LCG)
// LCG(2^32, 3*7*11*13*23, 0, seed)
//
uint32_t rnd = l_rnd * (3U*7U*11U*13U*23U);
l_rnd = rnd; // set for the next time
QP::QK::schedUnlock(lockStat); // unlock sched after accessing l_rnd
return (rnd >> 8);
}
Precondition
The scheduler cannot be unlocked:
  • from the ISR context; and
  • the current lock priority must be greater than the previous

Definition at line 277 of file qk.cpp.

◆ onIdle()

static void onIdle ( void  )
static

QK idle callback (customized in BSPs for QK)

Description
QP::QK::onIdle() is called continously 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
QP::QK::onIdle() is invoked with interrupts enabled and must also return with interrupts enabled.
See also
QP::QF::onIdle()

◆ getVersion()

static char_t const* getVersion ( void  )
inlinestaticnoexcept

get the current QK version number string of the form X.Y.Z

Definition at line 155 of file qk.hpp.


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