qk.h File Reference

QK/C++ platform-independent public interface. More...

#include "qequeue.h"
#include "qmpool.h"
#include "qpset.h"
#include "qs_port.h"

Go to the source code of this file.

Classes

class  QK
 QK services. More...

Defines

#define QF_EQUEUE_TYPE   QEQueue
 This macro defines the type of the event queue used for the active objects.
#define QF_OS_OBJECT_TYPE   uint8_t
 This macro defines the type of the OS-Object used for blocking the native QF event queue when the queue is empty.
#define QF_THREAD_TYPE   void *
 This macro defines the type of the thread handle used for the active objects.
#define QACTIVE_EQUEUE_WAIT_(me_)   Q_ASSERT((me_)->m_eQueue.m_frontEvt != (QEvent *)0)
 Platform-dependent macro defining how QF should block the calling task when the QF native queue is empty.
#define QACTIVE_EQUEUE_SIGNAL_(me_)
 Platform-dependent macro defining how QF should signal the active object task that an event has just arrived.
#define QACTIVE_EQUEUE_ONEMPTY_(me_)   QK_readySet_.remove((me_)->m_prio)
 Platform-dependent macro defining the action QF should take when the native QF event queue becomes empty.
#define QF_EPOOL_TYPE_   QMPool
 This macro defines the type of the event pool used in this QF port.
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_)   (p_).init(poolSto_, poolSize_, evtSize_)
 Platform-dependent macro defining the event pool initialization.
#define QF_EPOOL_EVENT_SIZE_(p_)   ((p_).getBlockSize())
 Platform-dependent macro defining how QF should obtain the event pool block-size.
#define QF_EPOOL_GET_(p_, e_)   ((e_) = (QEvent *)(p_).get())
 Platform-dependent macro defining how QF should obtain an event e_ from the event pool p_.
#define QF_EPOOL_PUT_(p_, e_)   ((p_).put(e_))
 Platform-dependent macro defining how QF should return an event e_ to the event pool p_.
#define QK_SCHEDULE_()   QK_schedule_(intLockKey_)

Typedefs

typedef uint8_t QMutex
 QK Mutex type.

Functions

void QK_init (void)
 QK initialization.
void QK_schedule_ (QF_INT_KEY_TYPE intLockKey)
 The QK scheduler.
void QK_scheduleExt_ (QF_INT_KEY_TYPE intLockKey)
 The QK extended scheduler for interrupt context.

Variables

QPSet64 volatile QK_readySet_
 ready set of QK
uint8_t volatile QK_currPrio_
 current task/interrupt priority
uint8_t volatile QK_intNest_
 interrupt nesting level

Detailed Description

QK/C++ platform-independent public interface.

This header file must be included directly or indirectly in all modules (*.cpp files) that use QK/C++.

Definition in file qk.h.


Define Documentation

#define QACTIVE_EQUEUE_ONEMPTY_ ( me_   )     QK_readySet_.remove((me_)->m_prio)

Platform-dependent macro defining the action QF should take when the native QF event queue becomes empty.

Note:
QACTIVE_EQUEUE_ONEMPTY_ is called from a critical section. It should not leave the critical section.
This is just an example of QACTIVE_EQUEUE_ONEMPTY_ for the QK-port of QF. In other QF ports you need to define the macro appropriately for the underlying kernel/OS you're using.

Definition at line 129 of file qk.h.

Referenced by QActive::get_().

#define QACTIVE_EQUEUE_SIGNAL_ ( me_   ) 
Value:
QK_readySet_.insert((me_)->m_prio); \
    if (QK_intNest_ == (uint8_t)0) { \
        QK_SCHEDULE_(); \
    } else ((void)0)

Platform-dependent macro defining how QF should signal the active object task that an event has just arrived.

The macro is necessary only when the native QF event queue is used. The signaling of task involves unblocking the task if it is blocked.

Note:
QACTIVE_EQUEUE_SIGNAL_ is called from a critical section. It might leave the critical section internally, but must restore the critical section before exiting to the caller.
This is just an example of QACTIVE_EQUEUE_SIGNAL_ for the QK-port of QF. In other QF ports you need to define the macro appropriately for the underlying kernel/OS you're using.

Definition at line 114 of file qk.h.

Referenced by QActive::postFIFO(), and QActive::postLIFO().

#define QACTIVE_EQUEUE_WAIT_ ( me_   )     Q_ASSERT((me_)->m_eQueue.m_frontEvt != (QEvent *)0)

Platform-dependent macro defining how QF should block the calling task when the QF native queue is empty.

Note:
This is just an example of QACTIVE_EQUEUE_WAIT_ for the QK-port of QF. QK never activates a task that has no events to process, so in this case the macro asserts that the queue is not empty. In other QF ports you using.

Definition at line 98 of file qk.h.

Referenced by QActive::get_().

#define QF_EPOOL_EVENT_SIZE_ ( p_   )     ((p_).getBlockSize())

Platform-dependent macro defining how QF should obtain the event pool block-size.

Note:
This is just an example of QF_EPOOL_EVENT_SIZE_ for the QK-port of QF. In other QF ports you need to define the macro appropriately for the underlying kernel/OS you're using.

Definition at line 156 of file qk.h.

Referenced by QF::new_(), and QF::poolInit().

#define QF_EPOOL_GET_ ( p_,
e_   )     ((e_) = (QEvent *)(p_).get())

Platform-dependent macro defining how QF should obtain an event e_ from the event pool p_.

Note:
This is just an example of QF_EPOOL_GET_ for the QK-port of QF. In other QF ports you need to define the macro appropriately for the underlying kernel/OS you're using.

Definition at line 164 of file qk.h.

Referenced by QF::new_().

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

Platform-dependent macro defining the event pool initialization.

Note:
This is just an example of QF_EPOOL_INIT_ for the QK-port of QF. In other QF ports you need to define the macro appropriately for the underlying kernel/OS you're using.

Definition at line 147 of file qk.h.

Referenced by QF::poolInit().

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

Platform-dependent macro defining how QF should return an event e_ to the event pool p_.

Note:
This is just an example of QF_EPOOL_PUT_ for the QK-port of QF. In other QF ports you need to define the macro appropriately for the underlying kernel/OS you're using.

Definition at line 172 of file qk.h.

Referenced by QF::gc().

#define QF_EPOOL_TYPE_   QMPool

This macro defines the type of the event pool used in this QF port.

Note:
This is just an example of the macro definition. Typically, you need to define it in the specific QF port file (qf_port.h). In case of QK, which always depends on the native QF memory pool, this macro is defined at the level of the platform-independent interface qk.h.

Definition at line 140 of file qk.h.

#define QF_EQUEUE_TYPE   QEQueue

This macro defines the type of the event queue used for the active objects.

Note:
This is just an example of the macro definition. Typically, you need to define it in the specific QF port file (qf_port.h). In case of QK, which always depends on the native QF queue, this macro is defined at the level of the platform-independent interface qk.h.

Definition at line 53 of file qk.h.

#define QF_OS_OBJECT_TYPE   uint8_t

This macro defines the type of the OS-Object used for blocking the native QF event queue when the queue is empty.

In QK, the OS object is used to hold the per-thread flags, which might be used, for example, to rembember the thread attributes (e.g., if the thread uses a floating point co-processor). The OS object value is set on per-thread basis in QActive::start(). Later, the extended context switch macros (QK_EXT_SAVE() and QK_EXT_RESTORE()) might use the per-thread flags to determine what kind of extended context switch this particular thread needs (e.g., the thread might not be using the coprocessor or might be using a different one).

Definition at line 67 of file qk.h.

#define QF_THREAD_TYPE   void *

This macro defines the type of the thread handle used for the active objects.

The thread type in QK is the pointer to the thread-local storage (TLS) This thread-local storage can be set on per-thread basis in QActive::start(). Later, the QK scheduler, passes the pointer to the thread-local storage to the macro QK_TLS.

Definition at line 76 of file qk.h.

 
#define QK_SCHEDULE_ (  )     QK_schedule_(intLockKey_)

QF_INT_KEY_TYPE is defined, this internal macro invokes QK_schedule_() passing the key variable as the parameter. Otherwise QK_schedule_() is invoked without parameters.

See also:
QK_INT_LOCK, QK_INT_UNLOCK

Definition at line 308 of file qk.h.

Referenced by QK::getVersion(), and QK::mutexUnlock().


Typedef Documentation

typedef uint8_t QMutex

QK Mutex type.

QMutex represents the priority-ceiling mutex available in QK.

See also:
QK::mutexLock()
QK::mutexUnlock()

Definition at line 181 of file qk.h.


Function Documentation

void QK_init ( void   ) 

QK initialization.

QK_init() is called from QF_init() in qk.cpp. This function is defined in the QK ports.

Referenced by QK::getVersion().

void QK_schedule_ ( QF_INT_KEY_TYPE  intLockKey_  ) 

The QK scheduler.

Note:
The QK scheduler must be always called with the interrupts locked and unlocks interrupts internally.

The signature of QK_schedule_() depends on the policy of locking and unlocking interrupts. When the interrupt lock key is not used (QF_INT_KEY_TYPE undefined), the signature is as follows:
void QK_schedule_(void);

However, when the interrupt key lock is used (QF_INT_KEY_TYPE defined), the signature is different:
void QK_schedule_(QF_INT_KEY_TYPE intLockKey);

For the internal use, these differences are hidden by the macro QK_SCHEDULE_.

Definition at line 42 of file qk_sched.cpp.

References QF::active_, QS::aoObj_, QPSet64::findMax(), QF::gc(), QActive::get_(), QPSet8::notEmpty(), Q_REQUIRE, QK_ceilingPrio_, QK_currPrio_, QK_INT_LOCK_, QK_INT_UNLOCK_, QK_intNest_, QK_readySet_, QK_TLS, QS_BEGIN_NOLOCK_, QS_END_NOLOCK_, QS_QK_SCHEDULE, QS_TIME_, and QS_U8_.

void QK_scheduleExt_ ( QF_INT_KEY_TYPE  intLockKey_  ) 

The QK extended scheduler for interrupt context.

Note:
The QK extended exscheduler must be always called with the interrupts locked and unlocks interrupts internally.

The signature of QK_scheduleExt_() depends on the policy of locking and unlocking interrupts. When the interrupt lock key is not used (QF_INT_KEY_TYPE undefined), the signature is as follows:
void QK_scheduleExt_(void);

However, when the interrupt key lock is used (QF_INT_KEY_TYPE defined), the signature is different:
void QK_scheduleExt_(QF_INT_KEY_TYPE intLockKey);

Definition at line 42 of file qk_ext.cpp.

References QF::active_, QS::aoObj_, QPSet64::findMax(), QF::gc(), QActive::get_(), Q_REQUIRE, QK_ceilingPrio_, QK_currPrio_, QK_EXT_RESTORE, QK_EXT_SAVE, QK_INT_LOCK_, QK_INT_UNLOCK_, QK_intNest_, QK_readySet_, QK_TLS, QS_BEGIN_NOLOCK_, QS_END_NOLOCK_, QS_QK_SCHEDULE, QS_TIME_, and QS_U8_.


Generated by  doxygen 1.6.2