QP/C++  6.5.1
qxk.h File Reference

QXK/C++ preemptive extended (blocking) kernel, platform-independent public interface. More...

#include "qequeue.h"
#include "qmpool.h"
#include "qpset.h"
Include dependency graph for qxk.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  QXK_Attr
 attributes of the QXK kernel More...
 
class  QXK
 QXK services. More...
 

Namespaces

 QP
 namespace associated with the QP/C++ framework
 

Macros

#define QF_EQUEUE_TYPE   QEQueue
 Kernel-dependent type of the event queue used for QXK threads. More...
 
#define QF_OS_OBJECT_TYPE   void*
 Kernel-dependent OS-attribute of threads in QXK. More...
 
#define QF_THREAD_TYPE   void*
 Kernel-dependent type of the thread attribute in QXK. More...
 
#define QXK_TLS(type_)   (static_cast<type_>(QXK_current()->m_thread))
 Access Thread-Local Storage (TLS) and cast it on the given type_. More...
 
#define QXK_ISR_CONTEXT_()   (QXK_attr_.intNest != static_cast<uint_fast8_t>(0))
 Internal port-specific macro that reports the execution context. More...
 
#define QF_SCHED_STAT_   QSchedStatus lockStat_;
 Internal macro to represent the scheduler lock status. More...
 
#define QF_SCHED_LOCK_(prio_)
 Internal macro for selective scheduler locking. More...
 
#define QF_SCHED_UNLOCK_()
 Internal macro for selective scheduler unlocking. More...
 
#define QACTIVE_EQUEUE_WAIT_(me_)   Q_ASSERT_ID(110, (me_)->m_eQueue.m_frontEvt != static_cast<QEvt *>(0))
 
#define QACTIVE_EQUEUE_SIGNAL_(me_)
 
#define QF_EPOOL_TYPE_   QMPool
 
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_)   (p_).init((poolSto_), (poolSize_), (evtSize_))
 
#define QF_EPOOL_EVENT_SIZE_(p_)   static_cast<uint_fast16_t>((p_).getBlockSize())
 
#define QF_EPOOL_GET_(p_, e_, m_)   ((e_) = static_cast<QEvt *>((p_).get((m_))))
 
#define QF_EPOOL_PUT_(p_, e_)   ((p_).put(e_))
 

Functions

uint_fast8_t QXK_sched_ (void)
 QXK scheduler finds the highest-priority thread ready to run. More...
 
void QXK_activate_ (void)
 QXK activator activates the next active object. The activated AO preempts. More...
 
QP::QActiveQXK_current (void)
 return the currently executing active-object/thread More...
 
void QXK_onContextSw (QP::QActive *prev, QP::QActive *next)
 QXK context switch callback (customized in BSPs for QXK) More...
 

Variables

QXK_Attr QXK_attr_
 global attributes of the QXK kernel More...
 

Detailed Description

QXK/C++ preemptive extended (blocking) kernel, platform-independent public interface.

Definition in file qxk.h.


Data Structure Documentation

◆ QXK_Attr

struct QXK_Attr

attributes of the QXK kernel

Definition at line 85 of file qxk.h.

Collaboration diagram for QXK_Attr:
Collaboration graph
Data Fields
QActive *volatile curr currently executing thread
QActive *volatile next next thread to execute
uint8_t volatile actPrio prio of the active basic thread
uint8_t volatile lockPrio lock prio (0 == no-lock)
uint8_t volatile lockHolder prio of the lock holder
uint8_t volatile intNest ISR nesting level.
QActive * idleThread pointer to the idle thread
QPSet readySet ready-set of basic- and extended-threads

Macro Definition Documentation

◆ QF_EQUEUE_TYPE

#define QF_EQUEUE_TYPE   QEQueue

Kernel-dependent type of the event queue used for QXK threads.

Description
QXK uses the native QF event queue QEQueue.

Definition at line 55 of file qxk.h.

◆ QF_OS_OBJECT_TYPE

#define QF_OS_OBJECT_TYPE   void*

Kernel-dependent OS-attribute of threads in QXK.

Description
QXK uses this member to store the private stack poiner for extended threads. (The private stack pointer is NULL for basic-threads).

Definition at line 63 of file qxk.h.

◆ QF_THREAD_TYPE

#define QF_THREAD_TYPE   void*

Kernel-dependent type of the thread attribute in QXK.

Description
QXK uses this member to store the private Thread-Local Storage pointer.

Definition at line 70 of file qxk.h.

◆ QXK_TLS

#define QXK_TLS (   type_)    (static_cast<type_>(QXK_current()->m_thread))

Access Thread-Local Storage (TLS) and cast it on the given type_.

Definition at line 73 of file qxk.h.

◆ QXK_ISR_CONTEXT_

#define QXK_ISR_CONTEXT_ ( )    (QXK_attr_.intNest != static_cast<uint_fast8_t>(0))

Internal port-specific macro that reports the execution context.

Returns
true if the code executes in the ISR context and false otherwise

Definition at line 194 of file qxk.h.

◆ QF_SCHED_STAT_

#define QF_SCHED_STAT_   QSchedStatus lockStat_;

Internal macro to represent the scheduler lock status.

Definition at line 202 of file qxk.h.

◆ QF_SCHED_LOCK_

#define QF_SCHED_LOCK_ (   prio_)
Value:
do { \
if (QXK_ISR_CONTEXT_()) { \
lockStat_ = static_cast<QSchedStatus>(0xFF); \
} else { \
lockStat_ = QXK::schedLock((prio_)); \
} \
} while (false)
#define QXK_ISR_CONTEXT_()
Internal port-specific macro that reports the execution context.
Definition: qxk.h:194

Internal macro for selective scheduler locking.

Definition at line 205 of file qxk.h.

◆ QF_SCHED_UNLOCK_

#define QF_SCHED_UNLOCK_ ( )
Value:
do { \
if (lockStat_ != static_cast<QSchedStatus>(0xFF)) { \
QXK::schedUnlock(lockStat_); \
} \
} while (false)

Internal macro for selective scheduler unlocking.

Definition at line 214 of file qxk.h.

◆ QACTIVE_EQUEUE_WAIT_

#define QACTIVE_EQUEUE_WAIT_ (   me_)    Q_ASSERT_ID(110, (me_)->m_eQueue.m_frontEvt != static_cast<QEvt *>(0))

Definition at line 221 of file qxk.h.

◆ QACTIVE_EQUEUE_SIGNAL_

#define QACTIVE_EQUEUE_SIGNAL_ (   me_)
Value:
do { \
QXK_attr_.readySet.insert(static_cast<uint_fast8_t>((me_)->m_prio)); \
if (!QXK_ISR_CONTEXT_()) { \
if (QXK_sched_() != static_cast<uint_fast8_t>(0)) { \
QXK_activate_(); \
} \
} \
} while (false)
#define QXK_ISR_CONTEXT_()
Internal port-specific macro that reports the execution context.
Definition: qxk.h:194
uint_fast8_t QXK_sched_(void)
QXK scheduler finds the highest-priority thread ready to run.

Definition at line 224 of file qxk.h.

◆ QF_EPOOL_TYPE_

#define QF_EPOOL_TYPE_   QMPool

Definition at line 234 of file qxk.h.

◆ QF_EPOOL_INIT_

#define QF_EPOOL_INIT_ (   p_,
  poolSto_,
  poolSize_,
  evtSize_ 
)    (p_).init((poolSto_), (poolSize_), (evtSize_))

Definition at line 235 of file qxk.h.

◆ QF_EPOOL_EVENT_SIZE_

#define QF_EPOOL_EVENT_SIZE_ (   p_)    static_cast<uint_fast16_t>((p_).getBlockSize())

Definition at line 237 of file qxk.h.

◆ QF_EPOOL_GET_

#define QF_EPOOL_GET_ (   p_,
  e_,
  m_ 
)    ((e_) = static_cast<QEvt *>((p_).get((m_))))

Definition at line 239 of file qxk.h.

◆ QF_EPOOL_PUT_

#define QF_EPOOL_PUT_ (   p_,
  e_ 
)    ((p_).put(e_))

Definition at line 241 of file qxk.h.

Function Documentation

◆ QXK_sched_()

uint_fast8_t QXK_sched_ ( void  )

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

◆ QXK_activate_()

void QXK_activate_ ( void  )

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

◆ QXK_current()

QP::QActive* QXK_current ( void  )

return the currently executing active-object/thread

◆ QXK_onContextSw()

void QXK_onContextSw ( QP::QActive prev,
QP::QActive next 
)

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.
extern "C" { // use the "C" calling convention
#ifdef QXK_ON_CONTEXT_SW
// NOTE: the context-switch callback is called with interrupts DISABLED
void QXK_onContextSw(QActive *prev, QActive *next) {
(void)prev;
if (next != (QActive *)0) { // next is not the QK idle loop?
_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, (void *)1)
QS_OBJ(prev);
QS_OBJ(next);
}
#endif // QXK_ON_CONTEXT_SW
} // extern "C"

Variable Documentation

◆ QXK_attr_

QXK_Attr QXK_attr_

global attributes of the QXK kernel