QP/C++  7.3.4
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qxk.hpp File Reference

QXK/C (preemptive dual-mode kernel) platform-independent public interface. More...

Go to the source code of this file.

Classes

class  QP::QXThread
 eXtended (blocking) thread of the QXK preemptive kernel More...
 
class  QP::QXSemaphore
 Counting Semaphore of the QXK preemptive kernel. More...
 
class  QP::QXMutex
 Blocking Mutex of the QXK preemptive kernel. More...
 
class  QXK_Attr
 Private attributes of the QXK kernel. More...
 

Namespaces

namespace  QP
 QP/C++ framework.
 
namespace  QP::QXK
 preemptive, dual-mode (non-blocking / blocking) kernel
 

Macros

#define QF_SCHED_STAT_   QSchedStatus lockStat_;
 
#define QF_SCHED_LOCK_(ceil_)
 
#define QF_SCHED_UNLOCK_()
 
#define QACTIVE_EQUEUE_WAIT_(me_)    Q_ASSERT_INCRIT(310, (me_)->m_eQueue.m_frontEvt != nullptr)
 
#define QACTIVE_EQUEUE_SIGNAL_(me_)
 
#define QXTHREAD_EQUEUE_SIGNAL_(me_)
 
#define QXTHREAD_CAST_(ptr_)   (static_cast<QP::QXThread *>(ptr_))
 
#define QXK_PTR_CAST_(type_, ptr_)   (reinterpret_cast<type_>(ptr_))
 
#define QF_EPOOL_TYPE_   QMPool
 
#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_)    (p_).init((poolSto_), (poolSize_), (evtSize_))
 
#define QF_EPOOL_EVENT_SIZE_(p_)   ((p_).getBlockSize())
 
#define QF_EPOOL_GET_(p_, e_, m_, qsId_)    ((e_) = static_cast<QEvt *>((p_).get((m_), (qsId_))))
 
#define QF_EPOOL_PUT_(p_, e_, qsId_)   ((p_).put((e_), (qsId_)))
 

Enumerations

enum  QP::QXK::TimeoutSigs : QSignal { QP::QXK::DELAY_SIG = 1U , QP::QXK::TIMEOUT_SIG }
 

Functions

void QP::QXK::onIdle ()
 
QSchedStatus QP::QXK::schedLock (std::uint_fast8_t const ceiling) noexcept
 
void QP::QXK::schedUnlock (QSchedStatus const stat) noexcept
 
QP::QActiveQP::QXK::current () noexcept
 
std::uint_fast8_t QXK_sched_ () noexcept
 
void QXK_activate_ () noexcept
 
void QXK_contextSw_ (QP::QActive *const next)
 
void QXK_threadExit_ ()
 

Variables

constexpr QTimeEvtCtr QP::QXTHREAD_NO_TIMEOUT {0U}
 
QXK_Attr QXK_priv_
 

Detailed Description

QXK/C (preemptive dual-mode kernel) platform-independent public interface.

Traceability
  • DVP-QP-MC4-D04_08

Definition in file qxk.hpp.

Macro Definition Documentation

◆ QF_SCHED_STAT_

#define QF_SCHED_STAT_   QSchedStatus lockStat_;

Definition at line 223 of file qxk.hpp.

◆ QF_SCHED_LOCK_

#define QF_SCHED_LOCK_ ( ceil_)
Value:
do { \
if (QXK_ISR_CONTEXT_()) { \
lockStat_ = 0xFFU; \
} else { \
lockStat_ = QXK::schedLock((ceil_)); \
} \
} while (false)
#define QXK_ISR_CONTEXT_()
Check if the code executes in the ISR context.
Definition qp_port.hpp:137

Definition at line 226 of file qxk.hpp.

◆ QF_SCHED_UNLOCK_

#define QF_SCHED_UNLOCK_ ( )
Value:
do { \
if (lockStat_ != 0xFFU) { \
QXK::schedUnlock(lockStat_); \
} \
} while (false)

Definition at line 235 of file qxk.hpp.

◆ QACTIVE_EQUEUE_WAIT_

#define QACTIVE_EQUEUE_WAIT_ ( me_)     Q_ASSERT_INCRIT(310, (me_)->m_eQueue.m_frontEvt != nullptr)

Definition at line 243 of file qxk.hpp.

◆ QACTIVE_EQUEUE_SIGNAL_

#define QACTIVE_EQUEUE_SIGNAL_ ( me_)
Value:
do { \
static_cast<std::uint_fast8_t>((me_)->m_prio)); \
if (!QXK_ISR_CONTEXT_()) { \
if (QXK_sched_() != 0U) { \
QXK_activate_(); \
} \
} \
} while (false)
void update_(QPSet *const dis) const noexcept
Definition qp.hpp:681
void insert(std::uint_fast8_t const n) noexcept
Definition qp.hpp:646
QP::QPSet readySet_dis
Definition qxk.hpp:195
QP::QPSet readySet
Definition qxk.hpp:192
QXK_Attr QXK_priv_
Definition qxk.cpp:174
std::uint_fast8_t QXK_sched_() noexcept
Definition qxk.cpp:177

Definition at line 249 of file qxk.hpp.

◆ QXTHREAD_EQUEUE_SIGNAL_

#define QXTHREAD_EQUEUE_SIGNAL_ ( me_)
Value:
do { \
if ((me_)->m_temp.obj == QXK_PTR_CAST_(QMState*, &(me_)->m_eQueue)) { \
static_cast<void>(QXTHREAD_CAST_(me_)->teDisarm_()); \
static_cast<std::uint_fast8_t>((me_)->m_prio)); \
if (!QXK_ISR_CONTEXT_()) { \
static_cast<void>(QXK_sched_()); \
} \
} \
} while (false)
#define QXTHREAD_CAST_(ptr_)
Definition qxk.hpp:305
#define QXK_PTR_CAST_(type_, ptr_)
Definition qxk.hpp:308

Definition at line 277 of file qxk.hpp.

◆ QXTHREAD_CAST_

#define QXTHREAD_CAST_ ( ptr_)    (static_cast<QP::QXThread *>(ptr_))

Internal macro to encapsulate casting of pointers for MISRA deviations

Description
This macro is specifically and exclusively used for downcasting pointers to QActive to pointers to QXThread in situations when it is known that such downcasting is correct.However, such pointer casting is not compliant with MISRA-C:2023 Rule 11.3(R) as well as other messages (e.g., PC-Lint-Plus warning 826). Defining this specific macro for this purpose allows to selectively disable the warnings for this particular case.
Traceability
  • DVR-QP-MC4-R11_03C
  • DVP-QP-PCLP-826

Definition at line 305 of file qxk.hpp.

◆ QXK_PTR_CAST_

#define QXK_PTR_CAST_ ( type_,
ptr_ )   (reinterpret_cast<type_>(ptr_))

Internal macro to encapsulate casting of pointers for MISRA deviations

Description
This macro is specifically and exclusively used for casting pointers that are never de-referenced, but only used for internal bookkeeping and checking (via assertions) the correct operation of the QXK kernel. Such pointer casting is not compliant with MISRA-C:2023-Rule 11.3(R) as well as other messages (e.g., PC-Lint-Plus warning 826). Defining this specific macro for this purpose allows to selectively disable the warnings for this particular case.
Traceability
  • DVR-QP-MC4-R11_05
  • DVP-QP-PCLP-826

Definition at line 308 of file qxk.hpp.

◆ QF_EPOOL_TYPE_

#define QF_EPOOL_TYPE_   QMPool

Definition at line 314 of file qxk.hpp.

◆ QF_EPOOL_INIT_

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

Definition at line 317 of file qxk.hpp.

◆ QF_EPOOL_EVENT_SIZE_

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

Definition at line 321 of file qxk.hpp.

◆ QF_EPOOL_GET_

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

Definition at line 324 of file qxk.hpp.

◆ QF_EPOOL_PUT_

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

Definition at line 328 of file qxk.hpp.

Function Documentation

◆ QXK_sched_()

QXK_sched_ ( )
noexcept

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. QXK_sched_() is defined with the "C" linkage (extern "C").

Definition at line 177 of file qxk.cpp.

◆ QXK_activate_()

QXK_activate_ ( )
noexcept

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. QXK_activate_() is defined with the "C" linkage (extern "C").

Definition at line 236 of file qxk.cpp.

◆ QXK_contextSw_()

void QXK_contextSw_ ( QP::QActive *const next)

Definition at line 338 of file qxk.cpp.

◆ QXK_threadExit_()

QXK_threadExit_ ( )

Called when QP::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 366 of file qxk.cpp.

Variable Documentation

◆ QXK_priv_

QXK_Attr QXK_priv_
extern

Definition at line 174 of file qxk.cpp.