|
ChibiOS/RT
2.5.1 |
|
This module implements the Condition Variables mechanism. Condition variables are an extensions to the Mutex subsystem and cannot work alone.
The condition variable is a synchronization object meant to be used inside a zone protected by a Mutex. Mutexes and CondVars together can implement a Monitor construct.
CH_USE_CONDVARS option must be enabled in chconf.h. Data Structures | |
| struct | CondVar |
| CondVar structure. More... | |
Functions | |
| void | chCondInit (CondVar *cp) |
Initializes s CondVar structure. | |
| void | chCondSignal (CondVar *cp) |
| Signals one thread that is waiting on the condition variable. | |
| void | chCondSignalI (CondVar *cp) |
| Signals one thread that is waiting on the condition variable. | |
| void | chCondBroadcast (CondVar *cp) |
| Signals all threads that are waiting on the condition variable. | |
| void | chCondBroadcastI (CondVar *cp) |
| Signals all threads that are waiting on the condition variable. | |
| msg_t | chCondWait (CondVar *cp) |
| Waits on the condition variable releasing the mutex lock. | |
| msg_t | chCondWaitS (CondVar *cp) |
| Waits on the condition variable releasing the mutex lock. | |
| msg_t | chCondWaitTimeout (CondVar *cp, systime_t time) |
| Waits on the condition variable releasing the mutex lock. | |
| msg_t | chCondWaitTimeoutS (CondVar *cp, systime_t time) |
| Waits on the condition variable releasing the mutex lock. | |
Defines | |
| #define | _CONDVAR_DATA(name) {_THREADSQUEUE_DATA(name.c_queue)} |
| Data part of a static condition variable initializer. | |
| #define | CONDVAR_DECL(name) CondVar name = _CONDVAR_DATA(name) |
| Static condition variable initializer. | |
Typedefs | |
| typedef struct CondVar | CondVar |
| CondVar structure. | |
| void chCondInit | ( | CondVar * | cp | ) |
Initializes s CondVar structure.
| [out] | cp | pointer to a CondVar structure |
Definition at line 52 of file chcond.c.
References CondVar::c_queue, chDbgCheck, and queue_init.
| void chCondSignal | ( | CondVar * | cp | ) |
Signals one thread that is waiting on the condition variable.
| [in] | cp | pointer to the CondVar structure |
Definition at line 66 of file chcond.c.
References CondVar::c_queue, chDbgCheck, chSchWakeupS(), chSysLock, chSysUnlock, fifo_remove(), notempty, and RDY_OK.

| void chCondSignalI | ( | CondVar * | cp | ) |
Signals one thread that is waiting on the condition variable.
| [in] | cp | pointer to the CondVar structure |
Definition at line 87 of file chcond.c.
References CondVar::c_queue, chDbgCheck, chDbgCheckClassI(), chSchReadyI(), fifo_remove(), notempty, RDY_OK, and Thread::rdymsg.

| void chCondBroadcast | ( | CondVar * | cp | ) |
Signals all threads that are waiting on the condition variable.
| [in] | cp | pointer to the CondVar structure |
Definition at line 103 of file chcond.c.
References chCondBroadcastI(), chSchRescheduleS(), chSysLock, and chSysUnlock.

| void chCondBroadcastI | ( | CondVar * | cp | ) |
Signals all threads that are waiting on the condition variable.
| [in] | cp | pointer to the CondVar structure |
Definition at line 122 of file chcond.c.
References CondVar::c_queue, chDbgCheck, chDbgCheckClassI(), chSchReadyI(), fifo_remove(), ThreadsQueue::p_next, RDY_RESET, and Thread::rdymsg.
Referenced by chCondBroadcast().

Waits on the condition variable releasing the mutex lock.
Releases the currently owned mutex, waits on the condition variable, and finally acquires the mutex again. All the sequence is performed atomically.
| [in] | cp | pointer to the CondVar structure |
| RDY_OK | if the condvar has been signaled using chCondSignal(). |
| RDY_RESET | if the condvar has been signaled using chCondBroadcast(). |
Definition at line 151 of file chcond.c.
References chCondWaitS(), chSysLock, and chSysUnlock.

Waits on the condition variable releasing the mutex lock.
Releases the currently owned mutex, waits on the condition variable, and finally acquires the mutex again. All the sequence is performed atomically.
| [in] | cp | pointer to the CondVar structure |
| RDY_OK | if the condvar has been signaled using chCondSignal(). |
| RDY_RESET | if the condvar has been signaled using chCondBroadcast(). |
Definition at line 177 of file chcond.c.
References CondVar::c_queue, chDbgAssert, chDbgCheck, chDbgCheckClassS(), chMtxLockS(), chMtxUnlockS(), chSchGoSleepS(), currp, Thread::p_mtxlist, prio_insert(), Thread::rdymsg, THD_STATE_WTCOND, and Thread::wtobjp.
Referenced by chCondWait().

Waits on the condition variable releasing the mutex lock.
Releases the currently owned mutex, waits on the condition variable, and finally acquires the mutex again. All the sequence is performed atomically.
CH_USE_CONDVARS_TIMEOUT must be enabled in order to use this function. | [in] | cp | pointer to the CondVar structure |
| [in] | time | the number of ticks before the operation timeouts, the special values are handled as follow:
|
| RDY_OK | if the condvar has been signaled using chCondSignal(). |
| RDY_RESET | if the condvar has been signaled using chCondBroadcast(). |
| RDY_TIMEOUT | if the condvar has not been signaled within the specified timeout. |
Definition at line 226 of file chcond.c.
References chCondWaitTimeoutS(), chSysLock, and chSysUnlock.

Waits on the condition variable releasing the mutex lock.
Releases the currently owned mutex, waits on the condition variable, and finally acquires the mutex again. All the sequence is performed atomically.
CH_USE_CONDVARS_TIMEOUT must be enabled in order to use this function. | [in] | cp | pointer to the CondVar structure |
| [in] | time | the number of ticks before the operation timeouts, the special values are handled as follow:
|
| RDY_OK | if the condvar has been signaled using chCondSignal(). |
| RDY_RESET | if the condvar has been signaled using chCondBroadcast(). |
| RDY_TIMEOUT | if the condvar has not been signaled within the specified timeout. |
Definition at line 263 of file chcond.c.
References CondVar::c_queue, chDbgAssert, chDbgCheck, chDbgCheckClassS(), chMtxLockS(), chMtxUnlockS(), chSchGoSleepTimeoutS(), currp, prio_insert(), RDY_TIMEOUT, THD_STATE_WTCOND, and TIME_IMMEDIATE.
Referenced by chCondWaitTimeout().

| #define _CONDVAR_DATA | ( | name | ) | {_THREADSQUEUE_DATA(name.c_queue)} |
| #define CONDVAR_DECL | ( | name | ) | CondVar name = _CONDVAR_DATA(name) |
Static condition variable initializer.
Statically initialized condition variables require no explicit initialization using chCondInit().
| [in] | name | the name of the condition variable |