QP/C++  7.1.3
Real-Time Embedded Framework
Loading...
Searching...
No Matches
QP::QXK Namespace Reference

preemptive, dual-mode (non-blocking / blocking) kernel

Enumerations

enum  Timeouts : enum_t { DELAY_SIG = 1 , TIMEOUT_SIG }
 timeout signals for extended threads More...
 

Functions

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

Enumeration Type Documentation

◆ Timeouts

enum Timeouts : enum_t
Enumerator
DELAY_SIG 
TIMEOUT_SIG 

Definition at line 147 of file qxk.hpp.

Function Documentation

◆ onIdle()

void onIdle ( )

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
QXK::onIdle() is invoked with interrupts enabled and must also return with interrupts enabled.
See also
QK::onIdle(), QXK::onIdle()

◆ schedLock()

QSchedStatus schedLock ( std::uint_fast8_t const  ceiling)
noexcept

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);
}
QSchedStatus schedLock(std::uint_fast8_t const ceiling) noexcept
QXK selective scheduler lock.
Definition: qxk.cpp:77
void schedUnlock(QSchedStatus const stat) noexcept
QXK selective scheduler unlock.
Definition: qxk.cpp:114
std::uint_fast16_t QSchedStatus
The scheduler lock status used in some real-time kernels.
Definition: qf.hpp:208
Precondition
The QXK scheduler lock cannot be called from an ISR;
The QXK scheduler lock cannot be called from an ISR;

Definition at line 77 of file qxk.cpp.

◆ schedUnlock()

void schedUnlock ( QSchedStatus const  stat)
noexcept

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
The scheduler cannot be unlocked:
  • from the ISR context; and
  • the current lock priority must be greater than the previous

Definition at line 114 of file qxk.cpp.