QP/C++  8.0.3
Real-Time Event Framework
Loading...
Searching...
No Matches
qk.hpp
Go to the documentation of this file.
1//============================================================================
2// QP/C++ Real-Time Event Framework (RTEF)
3//
4// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
5//
6// Q u a n t u m L e a P s
7// ------------------------
8// Modern Embedded Software
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
11//
12// This software is dual-licensed under the terms of the open-source GNU
13// General Public License (GPL) or under the terms of one of the closed-
14// source Quantum Leaps commercial licenses.
15//
16// Redistributions in source code must retain this top-level comment block.
17// Plagiarizing this software to sidestep the license obligations is illegal.
18//
19// NOTE:
20// The GPL does NOT permit the incorporation of this code into proprietary
21// programs. Please contact Quantum Leaps for commercial licensing options,
22// which expressly supersede the GPL and are designed explicitly for
23// closed-source distribution.
24//
25// Quantum Leaps contact information:
26// <www.state-machine.com/licensing>
27// <info@state-machine.com>
28//============================================================================
29#ifndef QK_HPP_
30#define QK_HPP_
31
32namespace QP {
33
34using QSchedStatus = std::uint_fast8_t;
35
36} // namespace QP
37
38//============================================================================
39extern "C" {
40
41class QK_Attr {
42public:
44 std::uint_fast8_t actPrio;
45 std::uint_fast8_t nextPrio;
46 std::uint_fast8_t actThre;
47 std::uint_fast8_t lockCeil;
48 std::uint_fast8_t intNest;
49}; // class QK_Attr
50
51extern QK_Attr QK_priv_;
52
53std::uint_fast8_t QK_sched_() noexcept;
54
55std::uint_fast8_t QK_sched_act_(
56 QP::QActive const * const act,
57 std::uint_fast8_t const pthre_in) noexcept;
58
59void QK_activate_() noexcept;
60
61} // extern "C"
62
63//============================================================================
64namespace QP {
65namespace QK {
66
67QSchedStatus schedLock(std::uint_fast8_t const ceiling) noexcept;
68void schedUnlock(QSchedStatus const prevCeil) noexcept;
69void onIdle();
70
71} // namespace QK
72} // namespace QP
73
74//============================================================================
75// interface used only for internal implementation, but not in applications
76#ifdef QP_IMPL
77
78// scheduler locking for QK...
79#define QF_SCHED_STAT_ QSchedStatus lockStat_;
80#define QF_SCHED_LOCK_(ceil_) do { \
81 if (QK_ISR_CONTEXT_()) { \
82 lockStat_ = 0xFFU; \
83 } else { \
84 lockStat_ = QK::schedLock((ceil_)); \
85 } \
86} while (false)
87
88#define QF_SCHED_UNLOCK_() do { \
89 if (lockStat_ != 0xFFU) { \
90 QK::schedUnlock(lockStat_); \
91 } \
92} while (false)
93
94// QActive event queue customization for QK...
95#define QACTIVE_EQUEUE_WAIT_(me_) (static_cast<void>(0))
96#define QACTIVE_EQUEUE_SIGNAL_(me_) do { \
97 QK_priv_.readySet.insert( \
98 static_cast<std::uint_fast8_t>((me_)->m_prio)); \
99 if (!QK_ISR_CONTEXT_()) { \
100 if (QK_sched_() != 0U) { \
101 QK_activate_(); \
102 } \
103 } \
104} while (false)
105
106// QF event pool customization for QK...
107#define QF_EPOOL_TYPE_ QMPool
108#define QF_EPOOL_INIT_(p_, poolSto_, poolSize_, evtSize_) \
109 (p_).init((poolSto_), (poolSize_), (evtSize_))
110#define QF_EPOOL_EVENT_SIZE_(p_) ((p_).getBlockSize())
111#define QF_EPOOL_GET_(p_, e_, m_, qsId_) \
112 ((e_) = static_cast<QEvt *>((p_).get((m_), (qsId_))))
113#define QF_EPOOL_PUT_(p_, e_, qsId_) ((p_).put((e_), (qsId_)))
114
115#endif // QP_IMPL
116
117#endif // QK_HPP_
Private attributes of the QK kernel.
Definition qk.hpp:41
std::uint_fast8_t actThre
Definition qk.hpp:46
QP::QPSet readySet
Definition qk.hpp:43
std::uint_fast8_t nextPrio
Definition qk.hpp:45
std::uint_fast8_t actPrio
Definition qk.hpp:44
std::uint_fast8_t intNest
Definition qk.hpp:48
std::uint_fast8_t lockCeil
Definition qk.hpp:47
Set of Active Objects of up to QF_MAX_ACTIVE elements.
Definition qp.hpp:479
preemptive, non-blocking kernel
Definition qk.hpp:65
QSchedStatus schedLock(std::uint_fast8_t const ceiling) noexcept
Definition qk.cpp:54
void schedUnlock(QSchedStatus const prevCeil) noexcept
Definition qk.cpp:82
void onIdle()
QP/C++ framework.
Definition qequeue.hpp:36
std::uint_fast8_t QSchedStatus
Definition qk.hpp:34
void QK_activate_() noexcept
Definition qk.cpp:180
QK_Attr QK_priv_
Definition qk.cpp:115
std::uint_fast8_t QK_sched_act_(QP::QActive const *const act, std::uint_fast8_t const pthre_in) noexcept
Definition qk.cpp:145
std::uint_fast8_t QK_sched_() noexcept
Definition qk.cpp:118