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

preemptive, non-blocking kernel More...

Functions

QSchedStatus schedLock (std::uint_fast8_t const ceiling) noexcept
 
void schedUnlock (QSchedStatus const prevCeil) noexcept
 
void onIdle ()
 

Detailed Description

preemptive, non-blocking kernel

Details
The QK namespace contains only QK facilities callable from C++. The following other QK facilities are defined in the global namespace to be callable from assembly (as extern "C"):

Function Documentation

◆ schedLock()

QSchedStatus QP::QK::schedLock ( std::uint_fast8_t const ceiling)
noexcept

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().
Precondition qk:100
  • The QK scheduler lock cannot be called from an ISR
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() {
QP::QSchedStatus lockStat = QP::QK::schedLock(N_PHILO); // <== lock
std::uint32_rnd;
. . . // access/manipulate the shared random seed resource
return rnd;
}
QSchedStatus schedLock(std::uint_fast8_t const ceiling) noexcept
Definition qk.cpp:67
void schedUnlock(QSchedStatus const prevCeil) noexcept
Definition qk.cpp:106
std::uint_fast8_t QSchedStatus
Definition qk.hpp:42

Definition at line 67 of file qk.cpp.

◆ schedUnlock()

void QP::QK::schedUnlock ( QSchedStatus const stat)
noexcept

QK selective scheduler unlock

Details
This function unlocks the QK scheduler to the previous status.
Parameters
[in]statprevious QK Scheduler lock status returned from QK::schedLock()
Precondition qk:200
  • the QK scheduler cannot be unlocked: from the ISR context
  • the current lock ceiling must be greater than the previous
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() {
QP::QSchedStatus lockStat = QP::QK::schedLock(N_PHILO);
std::uint32_rnd;
. . . // access/manipulate the shared random seed resource
QP::QK::schedUnlock(lockStat); // <=== unlock
return rnd;
}

Definition at line 106 of file qk.cpp.

◆ onIdle()

void QP::QK::onIdle ( )

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.