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

preemptive, non-blocking kernel

Functions

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

Function Documentation

◆ onIdle()

void onIdle ( )

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.
See also
QV::onIdle(), QXK::onIdle()

◆ schedLock()

QSchedStatus schedLock ( std::uint_fast8_t const  ceiling)
noexcept

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

Definition at line 76 of file qk.cpp.

◆ schedUnlock()

void schedUnlock ( QSchedStatus const  stat)
noexcept

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

Definition at line 110 of file qk.cpp.