QP/C  6.1.1
qxthread.h
Go to the documentation of this file.
1 
40 #ifndef qxthread_h
41 #define qxthread_h
42 
43 /****************************************************************************/
71 typedef struct {
72  QActive super; /* inherit QActive */
73  QTimeEvt timeEvt; /* time event to handle timeouts */
74 } QXThread;
75 
83 
101 #define QXTHREAD_START(me_, prio_, qSto_, qLen_, stkSto_, stkLen_, param_) \
102  ((*((QActiveVtbl const *)((me_)->super.super.vptr))->start)( \
103  &(me_)->super, (prio_), (QEvt const **)(qSto_), (qLen_), \
104  (stkSto_), (stkLen_), (param_)))
105 
107 typedef void (*QXThreadHandler)(QXThread * const me);
108 
110 void QXThread_ctor(QXThread * const me, QXThreadHandler handler,
111  uint_fast8_t tickRate);
112 
141 #define QXTHREAD_POST_X(me_, e_, margin_, sender_) \
142  QACTIVE_POST_X(&(me_)->super, (e_), (margin_), (sender_))
143 
145 bool QXThread_delay(uint_fast16_t const nTicks);
146 
148 bool QXThread_delayCancel(QXThread * const me);
149 
151 QEvt const *QXThread_queueGet(uint_fast16_t const nTicks);
152 
154 #define QXTHREAD_NO_TIMEOUT ((uint_fast16_t)0)
155 
163 #define Q_XTHREAD_CAST(handler_) ((QXThreadHandler)(handler_))
164 
165 /****************************************************************************/
186 typedef struct {
188  uint16_t volatile count;
189  uint16_t max_count;
190 } QXSemaphore;
191 
193 void QXSemaphore_init(QXSemaphore * const me, uint_fast16_t count,
194  uint_fast16_t max_count);
195 
197 bool QXSemaphore_wait(QXSemaphore * const me,
198  uint_fast16_t const nTicks);
199 
201 bool QXSemaphore_tryWait(QXSemaphore * const me);
202 
204 bool QXSemaphore_signal(QXSemaphore * const me);
205 
206 
207 /****************************************************************************/
248 typedef struct {
250  uint8_t volatile lockNest;
251  uint8_t volatile holderPrio;
252  uint8_t ceiling;
253 } QXMutex;
254 
256 void QXMutex_init(QXMutex * const me, uint_fast8_t ceiling);
257 
259 bool QXMutex_lock(QXMutex * const me,
260  uint_fast16_t const nTicks);
261 
263 bool QXMutex_tryLock(QXMutex * const me);
264 
266 void QXMutex_unlock(QXMutex * const me);
267 
268 #endif /* qxthread_h */
269 
Counting Semaphore of the QXK preemptive kernel.
Definition: qxthread.h:186
Time Event structure.
Definition: qf.h:456
void(* QXThreadHandler)(QXThread *const me)
Thread handler pointer-to-function.
Definition: qxthread.h:107
bool QXThread_delayCancel(QXThread *const me)
cancel the delay
Definition: qxk_xthr.c:624
unsigned short uint16_t
exact-width 16-bit unsigned int
Definition: stdint.h:29
Virtual table for the QActive class.
Definition: qf.h:166
Blocking Mutex the QXK preemptive kernel.
Definition: qxthread.h:248
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: stdint.h:28
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)
Definition: qxk_xthr.c:396
bool QXSemaphore_wait(QXSemaphore *const me, uint_fast16_t const nTicks)
wait (block) on the semaphore
Definition: qxk_sema.c:113
eXtended (blocking) thread of the QXK preemptive kernel
Definition: qxthread.h:71
bool QXSemaphore_tryWait(QXSemaphore *const me)
try wait on the semaphore (non-blocking)
Definition: qxk_sema.c:173
void QXMutex_init(QXMutex *const me, uint_fast8_t ceiling)
initialize the QXK priority-ceiling mutex QXMutex
Definition: qxk_mutex.c:85
bool QXMutex_tryLock(QXMutex *const me)
try to lock the QXK priority-ceiling mutex QXMutex
Definition: qxk_mutex.c:242
unsigned int uint_fast8_t
fast at-least 8-bit unsigned int
Definition: stdint.h:35
bool QXSemaphore_signal(QXSemaphore *const me)
signal (unblock) the semaphore
Definition: qxk_sema.c:214
Event structure.
Definition: qep.h:153
QHsm super
inherits QHsm
Definition: qf.h:111
unsigned int uint_fast16_t
fast at-least 16-bit unsigned int
Definition: stdint.h:37
Priority Set of up to 32 elements.
Definition: qpset.h:56
void QXMutex_unlock(QXMutex *const me)
unlock the QXK priority-ceiling mutex QXMutex
Definition: qxk_mutex.c:332
void QXSemaphore_init(QXSemaphore *const me, uint_fast16_t count, uint_fast16_t max_count)
initialize the counting semaphore
Definition: qxk_sema.c:78
QPSet waitSet
set of extended-threads waiting on this semaphore
Definition: qxthread.h:187
bool QXThread_delay(uint_fast16_t const nTicks)
delay (block) the current extended thread for a specified # ticks
Definition: qxk_xthr.c:584
Active Object (based on QHsm implementation)
Definition: qf.h:110
void QXThread_ctor(QXThread *const me, QXThreadHandler handler, uint_fast8_t tickRate)
constructor of an extended-thread
Definition: qxk_xthr.c:94
bool QXMutex_lock(QXMutex *const me, uint_fast16_t const nTicks)
lock the QXK priority-ceiling mutex QXMutex
Definition: qxk_mutex.c:131