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

The QXK kernel class. More...

#include "qxk.h"

Static Public Member Functions

QActiveQXK_current (void)
 
void QXK_contextSw (QActive *const next)
 
void QXK_onIdle (void)
 
QSchedStatus QXK_schedLock (uint_fast8_t const ceiling)
 
void QXK_schedUnlock (QSchedStatus const stat)
 

Public Attributes

struct QActive *volatile curr
 
struct QActive *volatile next
 
struct QActive *volatile prev
 
uint8_t volatile actPrio
 
uint8_t volatile lockCeil
 
uint8_t volatile lockHolder
 

Private Types

enum  QXK_Timeouts
 

Static Private Member Functions

uint_fast8_t QXK_sched_ (void)
 
void QXK_activate_ (void)
 
void QXK_stackInit_ (void *thr, QXThreadHandler const handler, void *const stkSto, uint_fast16_t const stkSize)
 

Private Attributes

QXK QXK_attr_
 

Detailed Description

Note
The order and alignment of the data members in this struct might be important in QXK ports, where the members might be accessed in assembly.

Definition at line 80 of file qxk.h.

Member Enumeration Documentation

◆ QXK_Timeouts

enum QXK_Timeouts
private

timeout signals for extended threads

Definition at line 262 of file qxk.h.

Member Function Documentation

◆ QXK_sched_()

uint_fast8_t QXK_sched_ ( void  )
staticprivate

QXK scheduler finds the highest-priority thread ready to run

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

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

Precondition qxk:700
  • QXK_attr_.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 317 of file qxk.c.

◆ QXK_current()

QActive * 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 415 of file qxk.c.

◆ QXK_stackInit_()

void QXK_stackInit_ ( void *  thr,
QXThreadHandler const  handler,
void *const  stkSto,
uint_fast16_t const  stkSize 
)
staticprivate

initialize the private stack of a given AO (defined in QXK port)

◆ QXK_contextSw()

void QXK_contextSw ( QActive *const  next)
static

QXK context switch management

This function performs software tracing (if Q_SPY is defined) and calls QF_onContextSw() (if QF_ON_CONTEXT_SW 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 435 of file qxk.c.

◆ QXK_onIdle()

void QXK_onIdle ( void  )
static

QXK idle callback (customized in BSPs for QXK)

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 ( uint_fast8_t const  ceiling)
static

QXK Scheduler lock

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:400
  • 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) { /* 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: qf.h:217
QSchedStatus QXK_schedLock(uint_fast8_t const ceiling)

◆ QXK_schedUnlock()

void QXK_schedUnlock ( QSchedStatus const  stat)
static

QXK Scheduler unlock

This function unlocks the QXK scheduler to the previous status.

Parameters
[in]statprevious QXK Scheduler lock status returned from QXK_schedLock()
Precondition qxk:500
  • 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) { /* 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 108 of file qxk.c.

Member Data Documentation

◆ curr

struct QActive* volatile QXK::curr

current thread (NULL=basic)

Definition at line 81 of file qxk.h.

◆ next

struct QActive* volatile QXK::next

next thread to run

Definition at line 82 of file qxk.h.

◆ prev

struct QActive* volatile QXK::prev

previous thread

Definition at line 83 of file qxk.h.

◆ actPrio

uint8_t volatile QXK::actPrio

QF-prio of the active AO

Definition at line 84 of file qxk.h.

◆ lockCeil

uint8_t volatile QXK::lockCeil

lock-ceiling (0==no-lock)

Definition at line 85 of file qxk.h.

◆ lockHolder

uint8_t volatile QXK::lockHolder

prio of the lock holder

Definition at line 86 of file qxk.h.

◆ QXK_attr_

QXK QXK_attr_
private

attributes of the QXK kernel

Definition at line 93 of file qxk.h.


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