QP/C  7.0.1
Real-Time Embedded Framework
QXK Class Reference

The QXK kernel class. More...

#include <qxk.h>

Static Public Member Functions

void QXK_onContextSw (struct QActive *prev, struct QActive *next)
 
void QXK_onIdle (void)
 
struct QActiveQXK_current (void)
 
QSchedStatus QXK_schedLock (uint_fast8_t ceiling)
 
void QXK_schedUnlock (QSchedStatus stat)
 

Public Attributes

struct QActive *volatile curr
 
struct QActive *volatile next
 
uint8_t volatile actPrio
 
uint8_t volatile lockPrio
 
uint8_t volatile lockHolder
 
uint8_t volatile intNest
 
struct QActiveidleThread
 
QPSet readySet
 

Static Private Member Functions

uint_fast8_t QXK_sched_ (void)
 
void QXK_activate_ (void)
 

Private Attributes

QXK QXK_attr_
 

Detailed Description

Definition at line 64 of file qxk.h.

Member Function Documentation

◆ QXK_onContextSw()

void QXK_onContextSw ( struct QActive prev,
struct QActive next 
)
static

QXK context switch callback (customized in BSPs for QXK)

Description
This callback function provides a mechanism to perform additional custom operations when QXK switches context from one thread to another.
Parameters
[in]prevpointer to the previous thread (active object) (prev==0 means that prev was the QXK idle thread)
[in]nextpointer to the next thread (active object) (next==0) means that next is the QXK idle thread)
Attention
QXK_onContextSw() is invoked with interrupts disabled and must also return with interrupts disabled.
Note
This callback is enabled by defining the macro QXK_ON_CONTEXT_SW.
#ifdef QXK_ON_CONTEXT_SW
/* NOTE: the context-switch callback is called with interrupts DISABLED */
(void)prev;
if (next != (QActive *)0) { /* next is not the QXK idle thread? */
_impure_ptr = next->thread; /* switch to next TLS */
}
/* If you use QS software tracing, use the _NOCRIT() begin/end */
QS_BEGIN_NOCRIT(ON_CONTEXT_SW, 0U)
QS_OBJ(prev);
}
#endif /* QXK_ON_CONTEXT_SW */
#define QS_OBJ(obj_)
Definition: qs.h:814
#define QS_END_NOCRIT()
Definition: qs.h:698
#define QS_BEGIN_NOCRIT(rec_, qs_id_)
Definition: qs.h:692
Active Object base class (based on QHsm implementation)
Definition: qf.h:106
void QXK_onContextSw(struct QActive *prev, struct QActive *next)
struct QActive *volatile next
Definition: qxk.h:66

◆ QXK_onIdle()

void 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_sched_()

uint_fast8_t 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.
Attention
QXK_sched_() must be always called with interrupts disabled and returns with interrupts disabled.

Definition at line 227 of file qxk.c.

◆ QXK_activate_()

void QXK_activate_ ( void  )
staticprivate

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

Attention
QXK_activate_() must be always called with interrupts disabled and returns with interrupts disabled.
Note
The activate function might enable interrupts internally, but it always returns with interrupts disabled.

Definition at line 294 of file qxk.c.

◆ QXK_current()

struct QActive * QXK_current ( void  )
static

obtain the currently executing active-object/thread

Returns
pointer to the currently executing active-object/thread

Definition at line 424 of file qxk.c.

◆ QXK_schedLock()

QSchedStatus QXK_schedLock ( uint_fast8_t  ceiling)
static

QXK Scheduler lock

Description
This function locks the QXK scheduler to the specified ceiling.
Parameters
[in]ceilingpriority 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) { /* a very cheap pseudo-random-number generator */
uint32_t rnd;
QSchedStatus lockStat;
lockStat = QXK_schedLock(N_PHILO); /* <--- lock scheduler around shared seed */
/* "Super-Duper" Linear Congruential Generator (LCG) */
rnd = l_rnd * (3U*7U*11U*13U*23U);
l_rnd = rnd; /* set for the next time */
QXK_schedLock(lockStat); /* <--- unlock the scheduler */
return rnd;
}
uint_fast16_t QSchedStatus
Definition: qk.h:152
QSchedStatus QXK_schedLock(uint_fast8_t ceiling)
Definition: qxk.c:156

Definition at line 156 of file qxk.c.

◆ QXK_schedUnlock()

void QXK_schedUnlock ( QSchedStatus  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()
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().
See also
QXK_schedLock()
Usage
The following example shows how to lock and unlock the QXK scheduler:
uint32_t BSP_random(void) { /* a very cheap pseudo-random-number generator */
uint32_t rnd;
QSchedStatus lockStat;
lockStat = QXK_schedLock(N_PHILO); /* <--- lock scheduler around shared seed */
/* "Super-Duper" Linear Congruential Generator (LCG) */
rnd = l_rnd * (3U*7U*11U*13U*23U);
l_rnd = rnd; /* set for the next time */
QXK_schedLock(lockStat); /* <--- unlock the scheduler */
return rnd;
}

Definition at line 192 of file qxk.c.

Member Data Documentation

◆ curr

struct QActive* volatile curr

current thread pointer (NULL=basic)

Definition at line 65 of file qxk.h.

◆ next

struct QActive* volatile next

next thread pointer to execute

Definition at line 66 of file qxk.h.

◆ actPrio

uint8_t volatile actPrio

prio of the active AO

Definition at line 67 of file qxk.h.

◆ lockPrio

uint8_t volatile lockPrio

lock prio (0 == no-lock)

Definition at line 68 of file qxk.h.

◆ lockHolder

uint8_t volatile lockHolder

prio of the lock holder

Definition at line 69 of file qxk.h.

◆ intNest

uint8_t volatile intNest

ISR nesting level

Definition at line 70 of file qxk.h.

◆ idleThread

struct QActive* idleThread

pointer to the idle thread

Definition at line 71 of file qxk.h.

◆ readySet

QPSet readySet

ready-set of all threads

Definition at line 72 of file qxk.h.

◆ QXK_attr_

QXK QXK_attr_
private

global attributes of the QXK kernel

Definition at line 78 of file qxk.h.


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