QP/C  7.2.2
Real-Time Embedded Framework
Loading...
Searching...
No Matches
QK Class Reference

QK preemptive non-blocking kernel. More...

#include "qk.h"

Static Public Member Functions

QSchedStatus QK_schedLock (uint_fast8_t const ceiling)
 
void QK_schedUnlock (QSchedStatus const stat)
 
void QK_onIdle (void)
 

Public Attributes

uint8_t volatile actPrio
 
uint8_t volatile nextPrio
 
uint8_t volatile actThre
 
uint8_t volatile lockCeil
 
uint8_t volatile lockHolder
 

Static Private Member Functions

uint_fast8_t QK_sched_ (void)
 
void QK_activate_ (void)
 

Private Attributes

QK QK_attr_
 

Detailed Description

Definition at line 68 of file qk.h.

Member Function Documentation

◆ QK_sched_()

uint_fast8_t QK_sched_ ( void  )
staticprivate

QK scheduler finds the highest-priority AO ready to run

The QK scheduler finds out the priority of the highest-priority AO that (1) has events to process and (2) has priority that is above the current priority.

Returns
The QF-priority of the next active object to activate, or zero if no activation of AO is needed.
Attention
QK_sched_() must be always called with interrupts disabled and returns with interrupts disabled.

Definition at line 252 of file qk.c.

◆ QK_activate_()

void QK_activate_ ( void  )
staticprivate

QK activator activates the next active object. The activated AO preempts the currently executing AOs.

QK_activate_() activates ready-to run AOs that are above the initial preemption-threshold.

Precondition qk:500
  • QK_attr_.actPrio and QK_attr_.nextPrio must be in range
Attention
QK_activate_() must be always called with interrupts disabled and returns with interrupts disabled.

Definition at line 279 of file qk.c.

◆ QK_schedLock()

QSchedStatus QK_schedLock ( uint_fast8_t const  ceiling)
static

QK selective scheduler lock

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:600
  • 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:
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
uint32_t rnd;
QSchedStatus lockStat; /* <=== QK scheduler lock status */
lockStat = QK_schedLock(N_PHILO); /* <--- lock scheduler up to N_PHILO prio */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
rnd = l_rnd * (3U*7U*11U*13U*23U);
l_rnd = rnd; /* set for the next time */
QK_schedUnlock(lockStat); /* <--- unlock the scheduler */
return (rnd >> 8);
}
uint_fast16_t QSchedStatus
Definition: qf.h:217
QSchedStatus QK_schedLock(uint_fast8_t const ceiling)
void QK_schedUnlock(QSchedStatus const stat)
Definition: qk.c:105

◆ QK_schedUnlock()

void QK_schedUnlock ( QSchedStatus const  stat)
static

QK selective scheduler unlock

This function unlocks the QK scheduler to the previous status.

Parameters
[in]statprevious QK Scheduler lock status returned from QK_schedLock()
Precondition qk:700
  • 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:
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
uint32_t rnd;
QSchedStatus lockStat; /* <=== QK scheduler lock status */
lockStat = QK_schedLock(N_PHILO); /* <--- lock scheduler up to N_PHILO prio */
/* "Super-Duper" Linear Congruential Generator (LCG)
* LCG(2^32, 3*7*11*13*23, 0, seed)
*/
rnd = l_rnd * (3U*7U*11U*13U*23U);
l_rnd = rnd; /* set for the next time */
QK_schedUnlock(lockStat); /* <--- unlock the scheduler */
return (rnd >> 8);
}

Definition at line 105 of file qk.c.

◆ QK_onIdle()

void QK_onIdle ( void  )
static

QK idle callback (customized in BSPs for QK)

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.

Member Data Documentation

◆ actPrio

uint8_t volatile QK::actPrio

QF prio of the active AO

Definition at line 69 of file qk.h.

◆ nextPrio

uint8_t volatile QK::nextPrio

QF prio of the next AO to execute

Definition at line 70 of file qk.h.

◆ actThre

uint8_t volatile QK::actThre

active preemption-threshold

Definition at line 71 of file qk.h.

◆ lockCeil

uint8_t volatile QK::lockCeil

lock preemption-ceiling (0==no-lock)

Definition at line 72 of file qk.h.

◆ lockHolder

uint8_t volatile QK::lockHolder

QF prio of the AO holding the lock

Definition at line 73 of file qk.h.

◆ QK_attr_

QK QK_attr_
private

attributes of the QK kernel

Definition at line 80 of file qk.h.


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