QP/C 6.8.1
qxthread.h
Go to the documentation of this file.
1 
40 #ifndef QXTHREAD_H
41 #define QXTHREAD_H
42 
43 /****************************************************************************/
71 struct QXThread {
74 };
75 
83 
101 #define QXTHREAD_START(me_, prio_, qSto_, qLen_, stkSto_, stkLen_, par_) do {\
102  Q_ASSERT((me_)->super.super.vptr); \
103  ((*((QActiveVtable const *)((me_)->super.super.vptr))->start)( \
104  &(me_)->super, (prio_), (QEvt const **)(qSto_), (qLen_), \
105  (stkSto_), (stkLen_), (par_))); \
106 } while (false)
107 
109 void QXThread_ctor(QXThread * const me, QXThreadHandler handler,
110  uint_fast8_t tickRate);
111 
144 #define QXTHREAD_POST_X(me_, e_, margin_, sender_) \
145  QACTIVE_POST_X(&(me_)->super, (e_), (margin_), (sender_))
146 
148 bool QXThread_delay(uint_fast16_t const nTicks);
149 
151 bool QXThread_delayCancel(QXThread * const me);
152 
154 QEvt const *QXThread_queueGet(uint_fast16_t const nTicks);
155 
157 #define QXTHREAD_NO_TIMEOUT ((uint_fast16_t)0)
158 
159 /****************************************************************************/
180 typedef struct {
182  uint16_t volatile count;
184 } QXSemaphore;
185 
187 void QXSemaphore_init(QXSemaphore * const me, uint_fast16_t count,
188  uint_fast16_t max_count);
189 
191 bool QXSemaphore_wait(QXSemaphore * const me,
192  uint_fast16_t const nTicks);
193 
195 bool QXSemaphore_tryWait(QXSemaphore * const me);
196 
198 bool QXSemaphore_signal(QXSemaphore * const me);
199 
200 
201 /****************************************************************************/
242 typedef struct {
244  uint8_t volatile lockNest;
245  uint8_t volatile holderPrio;
247 } QXMutex;
248 
250 void QXMutex_init(QXMutex * const me, uint_fast8_t ceiling);
251 
253 bool QXMutex_lock(QXMutex * const me,
254  uint_fast16_t const nTicks);
255 
257 bool QXMutex_tryLock(QXMutex * const me);
258 
260 void QXMutex_unlock(QXMutex * const me);
261 
262 #endif /* QXTHREAD_H */
263 
uint8_t
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: 16bit/stdint.h:29
QXSemaphore
Counting Semaphore of the QXK preemptive kernel.
Definition: qxthread.h:180
QTimeEvt
Time Event class.
Definition: qf.h:480
QXSemaphore::max_count
uint16_t max_count
maximum value of the semaphore counter
Definition: qxthread.h:183
QXThread_ctor
void QXThread_ctor(QXThread *const me, QXThreadHandler handler, uint_fast8_t tickRate)
constructor of an extended-thread
Definition: qxk_xthr.c:108
QXSemaphore::waitSet
QPSet waitSet
set of extended-threads waiting on this semaphore
Definition: qxthread.h:181
QXSemaphore_init
void QXSemaphore_init(QXSemaphore *const me, uint_fast16_t count, uint_fast16_t max_count)
initialize the counting semaphore
Definition: qxk_sema.c:79
QActiveVtable
Virtual table for the QActive class.
Definition: qf.h:169
QXThread_delayCancel
bool QXThread_delayCancel(QXThread *const me)
cancel the delay
Definition: qxk_xthr.c:663
QXThread_delay
bool QXThread_delay(uint_fast16_t const nTicks)
delay (block) the current extended thread for a specified # ticks
Definition: qxk_xthr.c:623
QXMutex::ceiling
uint8_t ceiling
prioirty ceiling of this mutex
Definition: qxthread.h:246
QXThread
eXtended (blocking) thread of the QXK preemptive kernel
Definition: qxthread.h:71
QXThread_queueGet
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:430
uint16_t
unsigned int uint16_t
exact-width 16-bit unsigned int
Definition: 16bit/stdint.h:30
QActive
Active Object base class (based on QHsm implementation)
Definition: qf.h:116
uint_fast8_t
unsigned int uint_fast8_t
fast at-least 8-bit unsigned int
Definition: 16bit/stdint.h:36
QXSemaphore_signal
bool QXSemaphore_signal(QXSemaphore *const me)
signal (unblock) the semaphore
Definition: qxk_sema.c:241
QXMutex::holderPrio
uint8_t volatile holderPrio
priority of the lock holder thread
Definition: qxthread.h:245
QEvt
Event class.
Definition: qep.h:151
QXSemaphore::count
uint16_t volatile count
semaphore up-down counter
Definition: qxthread.h:182
QXThreadHandler
void(* QXThreadHandler)(QXThread *const me)
Pointer to a thread-handler function.
Definition: qep.h:216
QXMutex_init
void QXMutex_init(QXMutex *const me, uint_fast8_t ceiling)
initialize the QXK priority-ceiling mutex QXMutex
Definition: qxk_mutex.c:87
QXMutex_tryLock
bool QXMutex_tryLock(QXMutex *const me)
try to lock the QXK priority-ceiling mutex QXMutex
Definition: qxk_mutex.c:266
QXMutex::lockNest
uint8_t volatile lockNest
lock-nesting up-down counter
Definition: qxthread.h:244
QXThread::timeEvt
QTimeEvt timeEvt
time event to handle blocking timeouts
Definition: qxthread.h:73
QXThread::super
QActive super
inherited QActive
Definition: qxthread.h:72
QXMutex
Blocking Mutex the QXK preemptive kernel.
Definition: qxthread.h:242
QXMutex_unlock
void QXMutex_unlock(QXMutex *const me)
unlock the QXK priority-ceiling mutex QXMutex
Definition: qxk_mutex.c:356
QPSet
Priority Set of up to 32 elements.
Definition: qpset.h:68
QXSemaphore_wait
bool QXSemaphore_wait(QXSemaphore *const me, uint_fast16_t const nTicks)
wait (block) on the semaphore
Definition: qxk_sema.c:115
QXSemaphore_tryWait
bool QXSemaphore_tryWait(QXSemaphore *const me)
try wait on the semaphore (non-blocking)
Definition: qxk_sema.c:200
QXMutex_lock
bool QXMutex_lock(QXMutex *const me, uint_fast16_t const nTicks)
lock the QXK priority-ceiling mutex QXMutex
Definition: qxk_mutex.c:134
uint_fast16_t
unsigned int uint_fast16_t
fast at-least 16-bit unsigned int
Definition: 16bit/stdint.h:38
QXThreadVtable
QActiveVtable QXThreadVtable
Virtual Table for the QXThread class (inherited from QActiveVtable)
Definition: qxthread.h:82