QP/C  6.5.1
qxthread.h
Go to the documentation of this file.
1 
40 #ifndef qxthread_h
41 #define qxthread_h
42 
43 /****************************************************************************/
71 typedef struct {
74 } QXThread;
75 
83 
101 #define QXTHREAD_START(me_, prio_, qSto_, qLen_, stkSto_, stkLen_, par_) do {\
102  Q_ASSERT((me_)->super.super.vptr); \
103  ((*((QActiveVtbl const *)((me_)->super.super.vptr))->start)( \
104  &(me_)->super, (prio_), (QEvt const **)(qSto_), (qLen_), \
105  (stkSto_), (stkLen_), (par_))); \
106 } while (0)
107 
109 typedef void (*QXThreadHandler)(QXThread * const me);
110 
112 void QXThread_ctor(QXThread * const me, QXThreadHandler handler,
113  uint_fast8_t tickRate);
114 
147 #define QXTHREAD_POST_X(me_, e_, margin_, sender_) \
148  QACTIVE_POST_X(&(me_)->super, (e_), (margin_), (sender_))
149 
151 bool QXThread_delay(uint_fast16_t const nTicks);
152 
154 bool QXThread_delayCancel(QXThread * const me);
155 
157 QEvt const *QXThread_queueGet(uint_fast16_t const nTicks);
158 
160 #define QXTHREAD_NO_TIMEOUT ((uint_fast16_t)0)
161 
169 #define Q_XTHREAD_CAST(handler_) ((QXThreadHandler)(handler_))
170 
171 /****************************************************************************/
192 typedef struct {
194  uint16_t volatile count;
196 } QXSemaphore;
197 
199 void QXSemaphore_init(QXSemaphore * const me, uint_fast16_t count,
200  uint_fast16_t max_count);
201 
203 bool QXSemaphore_wait(QXSemaphore * const me,
204  uint_fast16_t const nTicks);
205 
207 bool QXSemaphore_tryWait(QXSemaphore * const me);
208 
210 bool QXSemaphore_signal(QXSemaphore * const me);
211 
212 
213 /****************************************************************************/
254 typedef struct {
256  uint8_t volatile lockNest;
257  uint8_t volatile holderPrio;
259 } QXMutex;
260 
262 void QXMutex_init(QXMutex * const me, uint_fast8_t ceiling);
263 
265 bool QXMutex_lock(QXMutex * const me,
266  uint_fast16_t const nTicks);
267 
269 bool QXMutex_tryLock(QXMutex * const me);
270 
272 void QXMutex_unlock(QXMutex * const me);
273 
274 #endif /* qxthread_h */
275 
Counting Semaphore of the QXK preemptive kernel.
Definition: qxthread.h:192
uint8_t ceiling
prioirty ceiling of this mutex
Definition: qxthread.h:258
uint8_t volatile lockNest
lock-nesting up-down counter
Definition: qxthread.h:256
Time Event structure.
Definition: qf.h:442
void(* QXThreadHandler)(QXThread *const me)
Thread handler pointer-to-function.
Definition: qxthread.h:109
bool QXThread_delayCancel(QXThread *const me)
cancel the delay
unsigned short uint16_t
exact-width 16-bit unsigned int
Definition: stdint.h:30
Virtual table for the QActive class.
Definition: qf.h:170
QActive super
inherited QActive
Definition: qxthread.h:72
Blocking Mutex the QXK preemptive kernel.
Definition: qxthread.h:254
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: stdint.h:29
QActiveVtbl QXThreadVtbl
Virtual Table for the QXThread class (inherited from QActiveVtbl)
Definition: qxthread.h:82
QEvt const * QXThread_queueGet(uint_fast16_t const nTicks)
obtain a message from the private message queue (block if no messages)
bool QXSemaphore_wait(QXSemaphore *const me, uint_fast16_t const nTicks)
wait (block) on the semaphore
eXtended (blocking) thread of the QXK preemptive kernel
Definition: qxthread.h:71
uint8_t volatile holderPrio
priority of the lock holder thread
Definition: qxthread.h:257
bool QXSemaphore_tryWait(QXSemaphore *const me)
try wait on the semaphore (non-blocking)
void QXMutex_init(QXMutex *const me, uint_fast8_t ceiling)
initialize the QXK priority-ceiling mutex QXMutex
bool QXMutex_tryLock(QXMutex *const me)
try to lock the QXK priority-ceiling mutex QXMutex
unsigned int uint_fast8_t
fast at-least 8-bit unsigned int
Definition: stdint.h:36
bool QXSemaphore_signal(QXSemaphore *const me)
signal (unblock) the semaphore
Event structure.
Definition: qep.h:153
QTimeEvt timeEvt
time event to handle blocking timeouts
Definition: qxthread.h:73
unsigned int uint_fast16_t
fast at-least 16-bit unsigned int
Definition: stdint.h:38
Priority Set of up to 32 elements.
Definition: qpset.h:63
void QXMutex_unlock(QXMutex *const me)
unlock the QXK priority-ceiling mutex QXMutex
void QXSemaphore_init(QXSemaphore *const me, uint_fast16_t count, uint_fast16_t max_count)
initialize the counting semaphore
uint16_t volatile count
semaphore up-down counter
Definition: qxthread.h:194
QPSet waitSet
set of extended-threads waiting on this semaphore
Definition: qxthread.h:193
bool QXThread_delay(uint_fast16_t const nTicks)
delay (block) the current extended thread for a specified # ticks
Active Object (based on QHsm implementation)
Definition: qf.h:114
uint16_t max_count
maximum value of the semaphore counter
Definition: qxthread.h:195
void QXThread_ctor(QXThread *const me, QXThreadHandler handler, uint_fast8_t tickRate)
constructor of an extended-thread
bool QXMutex_lock(QXMutex *const me, uint_fast16_t const nTicks)
lock the QXK priority-ceiling mutex QXMutex