QP/C 8.1.3
Real-Time Event Framework
Loading...
Searching...
No Matches
QXK Class Reference

QXK dual-mode kernel (QXK namespace emulated as a "class" in C). More...

#include <qxk.h>

Static Public Member Functions

void QXK_onIdle (void)
 QXK idle callback (customized in BSPs for QXK).
QSchedStatus QXK_schedLock (uint8_t const ceiling)
 QXK selective scheduler lock.
void QXK_schedUnlock (QSchedStatus const stat)
 QXK selective scheduler unlock.
QActiveQXK_current (void)
 Obtain the currently executing active-object/thread.
void QXK_contextSw_ (QActive *const next)
 QXK context switch management.

Static Private Member Functions

uint_fast8_t QXK_sched_ (void)
 QXK scheduler finds the highest-priority thread ready to run.
void QXK_activate_ (void)
 QXK activator activates the next AO that preempts the currently executing AOs.
void QXK_threadExit_ (void)
 called right before QXThread exits

Private Attributes

QXK_Attr QXK_priv_

Detailed Description

QXK dual-mode kernel (QXK namespace emulated as a "class" in C).

See also
Preemptive Non-Blocking Kernel The QXK class is related to the following classes:

Definition at line 33 of file qxk.h.

Member Function Documentation

◆ QXK_onIdle()

void QXK_onIdle ( void )
static

QXK idle callback (customized in BSPs for QXK).

Details
QXK_onIdle() is called continuously by the QXK idle thread. 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.

◆ QXK_schedLock()

QSchedStatus QXK_schedLock ( uint8_t const ceiling)
static

QXK selective scheduler lock.

Details
This function locks the QXK scheduler to the specified ceiling.

Parameters
[in]ceilingpreemption 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
A QXK scheduler can be locked from both basic threads (AOs) and extended threads and the scheduler locks can nest.
QXK_schedLock() must be always followed by the corresponding QXK_schedUnlock().
Attention
QXK will fire an assertion if a thread holding the lock attempts to block.
See also
QXK_schedUnlock()

Usage
The following example shows how to lock and unlock the QXK scheduler:

uint32_t BSP_random(void) {
uint32_rnd;
QSchedStatus lockStat = QXK_schedLock(N_PHILO); // <== N_PHILO ceiling
. . . // access/manipulate the shared random seed resource
QXK_schedUnlock(lockStat); // <=== unlock
return rnd;
}
uint_fast16_t QSchedStatus
Definition qxk.h:39
void QXK_schedUnlock(QSchedStatus const stat)
QXK selective scheduler unlock.
Definition qxk.c:84
QSchedStatus QXK_schedLock(uint8_t const ceiling)
QXK selective scheduler lock.
Definition qxk.c:51

Definition at line 51 of file qxk.c.

◆ QXK_schedUnlock()

void QXK_schedUnlock ( QSchedStatus const stat)
static

QXK selective scheduler unlock.

Details
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().

Usage
The following example shows how to lock and unlock the QXK scheduler:

uint32_t BSP_random(void) {
uint32_rnd;
QSchedStatus lockStat = QXK_schedLock(N_PHILO); // <== N_PHILO ceiling
. . . // access/manipulate the shared random seed resource
QXK_schedUnlock(lockStat); // <=== unlock
return rnd;
}

Definition at line 84 of file qxk.c.

◆ QXK_current()

QActive * QXK_current ( void )
static

Obtain the currently executing active-object/thread.

Details

Returns
pointer to the currently executing active-object/thread

Definition at line 119 of file qxk.c.

◆ QXK_sched_()

uint_fast8_t QXK_sched_ ( void )
staticprivate

QXK scheduler finds the highest-priority thread ready to run.

Details
The QXK scheduler finds the priority of the highest-priority thread that is ready to run.

Returns
the 1-based priority of the the thread (basic or extended) run next, or zero if no eligible thread is found.
Attention
QXK_sched_() must be always called with interrupts disabled and returns with interrupts disabled.

Definition at line 138 of file qxk.c.

◆ QXK_activate_()

void QXK_activate_ ( void )
staticprivate

QXK activator activates the next AO that preempts the currently executing AOs.

Details
QXK_activate_() activates ready-to run AOs that are above the initial active priority (QXK_priv_.actPrio).

Attention
QXK_activate_() must be always called with interrupts disabled and returns with interrupts disabled.

Definition at line 190 of file qxk.c.

◆ QXK_contextSw_()

void QXK_contextSw_ ( QActive *const next)
static

QXK context switch management.

Details
This internal function handles context switch. It calls QF_onContextSw() (if QF_ON_CONTEXT_SW is defined and performs software tracing (if Q_SPY is defined).

Parameters
[in]nextpointer to the next thread (NULL for basic-thread)
Attention
QXK_contextSw_() is invoked with interrupts disabled and must also return with interrupts disabled.

Definition at line 294 of file qxk.c.

◆ QXK_threadExit_()

void QXK_threadExit_ ( void )
staticprivate

called right before QXThread exits

Details
Called when the extended-thread handler function returns.

Note
Most thread handler functions are structured as endless loops that never return. But it is also possible to structure threads as one-shot functions that perform their job and return. In that case this function performs cleanup after the thread.

Definition at line 322 of file qxk.c.

Member Data Documentation

◆ QXK_priv_

QXK_Attr QXK_priv_
private

Definition at line 59 of file qxk.h.


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