QP/C  7.3.4
Real-Time Embedded 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)
 
QSchedStatus QXK_schedLock (uint_fast8_t const ceiling)
 
void QXK_schedUnlock (QSchedStatus const stat)
 
QActiveQXK_current (void)
 
void QXK_contextSw_ (QActive *const next)
 

Static Private Member Functions

uint_fast8_t QXK_sched_ (void)
 
void QXK_activate_ (void)
 
void QXK_threadExit_ (void)
 

Private Attributes

QXK_Attr QXK_priv_
 

Detailed Description

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

Description
The QXK class is related to the following classes:

Definition at line 50 of file qxk.h.

Member Function Documentation

◆ QXK_onIdle()

QXK::QXK_onIdle ( void )
static

QXK idle callback (customized in BSPs for QXK)

Description
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()

QXK::QXK_schedLock ( uint_fast8_t const ceiling)
static

QXK Scheduler lock

Description
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().
Precondition qxk:100
  • the QXK scheduler lock cannot be called from an ISR
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:60
void QXK_schedUnlock(QSchedStatus const stat)
Definition qxk.c:113
QSchedStatus QXK_schedLock(uint_fast8_t const ceiling)

◆ QXK_schedUnlock()

QXK::QXK_schedUnlock ( QSchedStatus const stat)
static

QXK Scheduler unlock

Description
This function unlocks the QXK scheduler to the previous status.
Parameters
[in]statprevious QXK Scheduler lock status returned from QXK_schedLock()
Precondition qxk:200
  • the QXK scheduler cannot be unlocked from the ISR context
Precondition qxk:501
  • the current lock ceiling must be greater than the previous
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 113 of file qxk.c.

◆ QXK_current()

QXK::QXK_current ( void )
static

Obtain the currently executing active-object/thread

Returns
pointer to the currently executing active-object/thread
Precondition qxk:800
  • the QXK kernel must be running
Postcondition qxk:890
  • the current thread must be valid

Definition at line 146 of file qxk.c.

◆ QXK_sched_()

QXK::QXK_sched_ ( void )
staticprivate

QXK scheduler finds the highest-priority thread ready to run

Description
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.
Precondition qxk:402
  • check the integrity of readySet_dis (duplicate inverse storage)
Attention
QXK_sched_() must be always called with interrupts disabled and returns with interrupts disabled.

Definition at line 168 of file qxk.c.

◆ QXK_activate_()

QXK::QXK_activate_ ( void )
staticprivate

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

Description
QXK_activate_() activates ready-to run AOs that are above the initial active priority (QXK_priv_.actPrio).
Precondition qxk:500
  • QXK_priv_.next must be valid and the prio must be in range
Attention
QXK_activate_() must be always called with interrupts disabled and returns with interrupts disabled.

Definition at line 223 of file qxk.c.

◆ QXK_contextSw_()

QXK::QXK_contextSw_ ( QActive *const next)
static

QXK context switch management

Description
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 328 of file qxk.c.

◆ QXK_threadExit_()

QXK::QXK_threadExit_ ( void )
staticprivate

Called when QXThread exits

Description
Called when the extended-thread handler function returns.
Precondition qxk:900
  • must NOT be called from an ISR;
  • must be called from an extended thread
Precondition qxk:901
  • the thread must NOT be holding a scheduler lock
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 356 of file qxk.c.

Member Data Documentation

◆ QXK_priv_

QXK_Attr QXK_priv_
private

Definition at line 105 of file qxk.h.


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