Blocking Mutex of the QXK preemptive kernel. More...
#include <qxk.h>
Public Member Functions | |
| void | QXMutex_init (QXMutex *const me, QPrioSpec const prioSpec) |
| Initialize the QXK priority-ceiling mutex QXMutex. | |
| bool | QXMutex_lock (QXMutex *const me, QTimeEvtCtr const nTicks) |
| Lock the QXK priority-ceiling mutex QXMutex. | |
| bool | QXMutex_tryLock (QXMutex *const me) |
| Try to lock the QXK priority-ceiling mutex QXMutex. | |
| void | QXMutex_unlock (QXMutex *const me) |
| Unlock the QXK priority-ceiling mutex QXMutex. | |
Private Member Functions | |
| bool | QXMutex_tryAcq_ (QXMutex *const me, QXThread *const curr) |
| void | QXMutex_relOneThr_ (QXMutex *const me) |
Private Attributes | |
| QActive | ao |
| Active object used as a placeholder AO for this mutex in QActive_registry_[]. | |
| QPSet | waitSet |
| Set of extended-threads waiting on this mutex. | |
Blocking Mutex of the QXK preemptive kernel.
Details
QXMutex is a blocking mutual exclusion mechanism that can also apply the priority-ceiling protocol to avoid unbounded priority inversion (if initialized with a non-zero ceiling priority, see QXMutex_init()). In that case, QXMutex requires its own unique QP priority level, which cannot be used by any thread or any other QXMutex.
If initialized with preemption-ceiling of zero, QXMutex does not use the priority-ceiling protocol and does not require a unique QP priority (see QXMutex_init()).
QXMutex is recursive (re-entrant), which means that it can be locked multiple times (up to 255 levels) by the same thread without causing deadlock.
QXMutex is primarily intended for the extended (blocking) threads, but can also be used by the basic threads through the non-blocking QXMutex_tryLock() API.
Usage
The following example illustrates how to instantiate and use the mutex to protect a shared resource (random seed of a pseudo-random number generator).
Initialize the QXK priority-ceiling mutex QXMutex.
Details
Initialize the QXK priority ceiling mutex.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | prioSpec | the priority specification for the mutex (See also QPrioSpec). This value might also be zero. |
Conversely, prioSpec != 0 means that the priority-ceiling protocol shall be used by this mutex. Such mutex will temporarily boost the priority and priority-threshold of the holding thread to the priority specification in prioSpec (see QPrioSpec).
Usage
The following example illustrates how to instantiate and use the mutex to protect a shared resource (random seed of a pseudo-random number generator).
Definition at line 48 of file qxk_mutex.c.
| bool QXMutex_lock | ( | QXMutex *const | me, |
| QTimeEvtCtr const | nTicks ) |
Lock the QXK priority-ceiling mutex QXMutex.
Details
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | nTicks | number of clock ticks (at the associated rate) to wait for the mutex. The value of QXTHREAD_NO_TIMEOUT indicates that no timeout will occur and the mutex could block indefinitely. |
Usage
The following example illustrates how to instantiate and use the mutex to protect a shared resource (random seed of a pseudo-random number generator).
Definition at line 151 of file qxk_mutex.c.
| bool QXMutex_tryLock | ( | QXMutex *const | me | ) |
Try to lock the QXK priority-ceiling mutex QXMutex.
Details
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
Definition at line 224 of file qxk_mutex.c.
| void QXMutex_unlock | ( | QXMutex *const | me | ) |
Unlock the QXK priority-ceiling mutex QXMutex.
Details
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
Usage
The following example illustrates how to instantiate and use the mutex to protect a shared resource (random seed of a pseudo-random number generator).
Definition at line 257 of file qxk_mutex.c.
Definition at line 69 of file qxk_mutex.c.
|
private |
Definition at line 334 of file qxk_mutex.c.
|
private |
|
private |