QP/C++  7.4.0-rc.1
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

Description
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

Description
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:76
void schedUnlock(QSchedStatus const prevCeil) noexcept
Definition qk.cpp:115
std::uint_fast8_t QSchedStatus
Definition qk.hpp:50

Definition at line 76 of file qk.cpp.

◆ schedUnlock()

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

QK selective scheduler unlock

Description
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 115 of file qk.cpp.

◆ onIdle()

void QP::QK::onIdle ( )

QK idle callback (customized in BSPs for QK)

Description
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.