QP/C++ 6.9.3
QXK Class Reference

QXK services. More...

#include <qxk.hpp>

Collaboration diagram for QXK:
Collaboration graph

Static Public Member Functions

static QSchedStatus schedLock (std::uint_fast8_t const ceiling) noexcept
 QXK selective scheduler lock. More...
 
static void schedUnlock (QSchedStatus const stat) noexcept
 QXK selective scheduler unlock. More...
 
static void onIdle (void)
 QXK idle callback (customized in BSPs for QXK) More...
 

Detailed Description

QXK services.

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

Definition at line 144 of file qxk.hpp.

Member Function Documentation

◆ schedLock()

QSchedStatus schedLock ( std::uint_fast8_t const  ceiling)
staticnoexcept

QXK selective scheduler lock.

Description
This function locks the QXK scheduler to the specified ceiling.
Parameters
[in]ceilingpriority 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
QXK::schedLock() must be always followed by the corresponding QXK::schedUnlock().
See also
QXK::schedUnlock()
Usage
The following example shows how to lock and unlock the QXK scheduler:
std::uint32_t BSP::random(void) {
// lock the scheduler around l_rnd up to the (N_PHILO + 1U) ceiling
QP::QSchedStatus lockStat = QP::QXK::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::QXK::schedUnlock(lockStat); // unlock sched after accessing l_rnd
return (rnd >> 8);
}
unsigned long int uint32_t
exact-width 32-bit unsigned int
Definition: 16bit/stdint.h:31
static QSchedStatus schedLock(std::uint_fast8_t const ceiling) noexcept
QXK selective scheduler lock.
Definition: qxk.cpp:238
static void schedUnlock(QSchedStatus const stat) noexcept
QXK selective scheduler unlock.
Definition: qxk.cpp:293
std::uint_fast16_t QSchedStatus
The scheduler lock status.
Definition: qk.hpp:119
Precondition
The QXK scheduler lock:
  • cannot be called from an ISR;

Definition at line 238 of file qxk.cpp.

◆ schedUnlock()

void schedUnlock ( QSchedStatus const  stat)
staticnoexcept

QXK selective scheduler unlock.

Description
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().
See also
QXK::schedLock()
Usage
The following example shows how to lock and unlock the QXK scheduler:
std::uint32_t BSP::random(void) {
// lock the scheduler around l_rnd up to the (N_PHILO + 1U) ceiling
QP::QSchedStatus lockStat = QP::QXK::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::QXK::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 293 of file qxk.cpp.

◆ onIdle()

static void onIdle ( void  )
static

QXK idle callback (customized in BSPs for QXK)

Description
QP::QXK::onIdle() is called continously by the QXK idle loop. This callback gives the application an opportunity to enter a power-saving CPU mode, or perform some other idle processing.
Note
QP::QXK::onIdle() is invoked with interrupts enabled and must also return with interrupts enabled.
See also
QP::QF::onIdle()

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