<ahref="chcond_8c.html">Go to the documentation of this file.</a><divclass="fragment"><preclass="fragment"><aname="l00001"></a>00001 <spanclass="comment">/*</span>
<aname="l00047"></a>00047 <spanclass="preprocessor">#include "<aclass="code"href="ch_8h.html"title="ChibiOS/RT main include file.">ch.h</a>"</span>
<aname="l00071"></a><aclass="code"href="group__condvars.html#gadddadb68e2a2ce061c7df0d647da9996">00071</a><spanclass="keywordtype">void</span><aclass="code"href="group__condvars.html#gadddadb68e2a2ce061c7df0d647da9996"title="Signals one thread that is waiting on the condition variable.">chCondSignal</a>(<aclass="code"href="struct_cond_var.html"title="CondVar structure.">CondVar</a> *cp) {
<aname="l00075"></a>00075 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00076"></a>00076 <spanclass="keywordflow">if</span> (<aclass="code"href="group__internals.html#ga8f6bea56a53acc44758fe61c98d68a4e"title="Evaluates to TRUE if the specified threads queue or list is not empty.">notempty</a>(&cp-><aclass="code"href="struct_cond_var.html#a0d320ca091de542fccfebabc7716f666"title="CondVar threads queue.">c_queue</a>))
<aname="l00077"></a>00077 <aclass="code"href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95"title="Wakes up a thread.">chSchWakeupS</a>(<aclass="code"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it.">fifo_remove</a>(&cp-><aclass="code"href="struct_cond_var.html#a0d320ca091de542fccfebabc7716f666"title="CondVar threads queue.">c_queue</a>), <aclass="code"href="group__scheduler.html#gae1c86078318e11c2fa57ee3c2ec69f61"title="Default thread wakeup low level message.">RDY_OK</a>);
<aname="l00078"></a>00078 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
<aname="l00086"></a><aclass="code"href="group__condvars.html#ga7b9d882c348124fed46a1afc3db6c02c">00086</a><spanclass="keywordtype">void</span><aclass="code"href="group__condvars.html#ga7b9d882c348124fed46a1afc3db6c02c"title="Signals one thread that is waiting on the condition variable.">chCondSignalI</a>(<aclass="code"href="struct_cond_var.html"title="CondVar structure.">CondVar</a> *cp) {
<aname="l00090"></a>00090 <spanclass="keywordflow">if</span> (<aclass="code"href="group__internals.html#ga8f6bea56a53acc44758fe61c98d68a4e"title="Evaluates to TRUE if the specified threads queue or list is not empty.">notempty</a>(&cp-><aclass="code"href="struct_cond_var.html#a0d320ca091de542fccfebabc7716f666"title="CondVar threads queue.">c_queue</a>))
<aname="l00091"></a>00091 <aclass="code"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List.">chSchReadyI</a>(<aclass="code"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it.">fifo_remove</a>(&cp-><aclass="code"href="struct_cond_var.html#a0d320ca091de542fccfebabc7716f666"title="CondVar threads queue.">c_queue</a>))-><aclass="code"href="struct_thread.html#a72cd0424b6098ca241fac1f74d21b56a"title="State-specific fields.">p_u</a>.<aclass="code"href="struct_thread.html#ad5792c30fbd60df0de223b0f398fc6d7"title="Thread wakeup code.">rdymsg</a> = RDY_OK;
<aname="l00099"></a><aclass="code"href="group__condvars.html#ga60c24a8060a884313efe82b8404e77f6">00099</a><spanclass="keywordtype">void</span><aclass="code"href="group__condvars.html#ga60c24a8060a884313efe82b8404e77f6"title="Signals all threads that are waiting on the condition variable.">chCondBroadcast</a>(<aclass="code"href="struct_cond_var.html"title="CondVar structure.">CondVar</a> *cp) {
<aname="l00100"></a>00100
<aname="l00101"></a>00101 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00102"></a>00102 <aclass="code"href="group__condvars.html#ga5cf1f4697985d81ee089b042391df6fc"title="Signals all threads that are waiting on the condition variable.">chCondBroadcastI</a>(cp);
<aname="l00103"></a>00103 <aclass="code"href="group__scheduler.html#ga4e38b4bee3d2330f6a0f1cdb7660af20"title="Performs a reschedule if a higher priority thread is runnable.">chSchRescheduleS</a>();
<aname="l00104"></a>00104 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
<aname="l00112"></a><aclass="code"href="group__condvars.html#ga5cf1f4697985d81ee089b042391df6fc">00112</a><spanclass="keywordtype">void</span><aclass="code"href="group__condvars.html#ga5cf1f4697985d81ee089b042391df6fc"title="Signals all threads that are waiting on the condition variable.">chCondBroadcastI</a>(<aclass="code"href="struct_cond_var.html"title="CondVar structure.">CondVar</a> *cp) {
<aname="l00120"></a>00120 <aclass="code"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List.">chSchReadyI</a>(<aclass="code"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it.">fifo_remove</a>(&cp-><aclass="code"href="struct_cond_var.html#a0d320ca091de542fccfebabc7716f666"title="CondVar threads queue.">c_queue</a>))-><aclass="code"href="struct_thread.html#a72cd0424b6098ca241fac1f74d21b56a"title="State-specific fields.">p_u</a>.<aclass="code"href="struct_thread.html#ad5792c30fbd60df0de223b0f398fc6d7"title="Thread wakeup code.">rdymsg</a> = RDY_RESET;
<aname="l00136"></a><aclass="code"href="group__condvars.html#ga466f912bc9b09b133fae862993004ffe">00136</a><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__condvars.html#ga466f912bc9b09b133fae862993004ffe"title="Waits on the condition variable releasing the mutex lock.">chCondWait</a>(<aclass="code"href="struct_cond_var.html"title="CondVar structure.">CondVar</a> *cp) {
<aname="l00137"></a>00137 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg;
<aname="l00138"></a>00138
<aname="l00139"></a>00139 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00140"></a>00140 msg = <aclass="code"href="group__condvars.html#gab6357d80b01ed8d225ef1e30a66248f9"title="Waits on the condition variable releasing the mutex lock.">chCondWaitS</a>(cp);
<aname="l00141"></a>00141 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
<aname="l00158"></a><aclass="code"href="group__condvars.html#gab6357d80b01ed8d225ef1e30a66248f9">00158</a><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__condvars.html#gab6357d80b01ed8d225ef1e30a66248f9"title="Waits on the condition variable releasing the mutex lock.">chCondWaitS</a>(<aclass="code"href="struct_cond_var.html"title="CondVar structure.">CondVar</a> *cp) {
<aname="l00161"></a>00161 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg;
<aname="l00164"></a>00164 <aclass="code"href="group__debug.html#ga43d50c69eb730d0f024eb832d61f30c9"title="Condition assertion.">chDbgAssert</a>(ctp-><aclass="code"href="struct_thread.html#a3ae80b4b3de4c7a23c542ca251e1f017"title="List of the mutexes owned by this thread.">p_mtxlist</a> != NULL,
<aname="l00166"></a>00166 <spanclass="stringliteral">"not owning a mutex"</span>);
<aname="l00167"></a>00167
<aname="l00168"></a>00168 mp = <aclass="code"href="group__mutexes.html#ga705fa60fb8aa28a6632f693e83f78c96"title="Unlocks the next owned mutex in reverse lock order.">chMtxUnlockS</a>();
<aname="l00169"></a>00169 ctp-><aclass="code"href="struct_thread.html#a72cd0424b6098ca241fac1f74d21b56a"title="State-specific fields.">p_u</a>.<aclass="code"href="struct_thread.html#a4f016b01444741e6f9b420436b748862"title="Pointer to a generic &quot;wait&quot; object.">wtobjp</a> = cp;
<aname="l00170"></a>00170 <aclass="code"href="group__internals.html#ga02226b866ae704435baf2ffe259ba0b2"title="Inserts a thread into a priority ordered queue.">prio_insert</a>(ctp, &cp-><aclass="code"href="struct_cond_var.html#a0d320ca091de542fccfebabc7716f666"title="CondVar threads queue.">c_queue</a>);
<aname="l00171"></a>00171 <aclass="code"href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986"title="Puts the current thread to sleep into the specified state.">chSchGoSleepS</a>(<aclass="code"href="group__threads.html#ga286c5b1a6459d654d5794fc17e93c939"title="Thread state: Waiting in chCondWait().">THD_STATE_WTCOND</a>);
<aname="l00173"></a>00173 <aclass="code"href="group__mutexes.html#ga2d6350c2d147d1165c359f30798205f5"title="Locks the specified mutex.">chMtxLockS</a>(mp);
<aname="l00200"></a><aclass="code"href="group__condvars.html#ga07a0c55ac1002a64e8c7f9b7e3ca1caf">00200</a><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__condvars.html#ga07a0c55ac1002a64e8c7f9b7e3ca1caf"title="Waits on the condition variable releasing the mutex lock.">chCondWaitTimeout</a>(<aclass="code"href="struct_cond_var.html"title="CondVar structure.">CondVar</a> *cp, <aclass="code"href="group__types.html#gae3e32a98d431a02106616da3071832dd"title="System Time, recommended fastest unsigned.">systime_t</a> time) {
<aname="l00201"></a>00201 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg;
<aname="l00202"></a>00202
<aname="l00203"></a>00203 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00204"></a>00204 msg = <aclass="code"href="group__condvars.html#ga9cf6ebe4c9f28cb206fab14984a18d29"title="Waits on the condition variable releasing the mutex lock.">chCondWaitTimeoutS</a>(cp, time);
<aname="l00205"></a>00205 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
<aname="l00231"></a><aclass="code"href="group__condvars.html#ga9cf6ebe4c9f28cb206fab14984a18d29">00231</a><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__condvars.html#ga9cf6ebe4c9f28cb206fab14984a18d29"title="Waits on the condition variable releasing the mutex lock.">chCondWaitTimeoutS</a>(<aclass="code"href="struct_cond_var.html"title="CondVar structure.">CondVar</a> *cp, <aclass="code"href="group__types.html#gae3e32a98d431a02106616da3071832dd"title="System Time, recommended fastest unsigned.">systime_t</a> time) {
<aname="l00233"></a>00233 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg;
<aname="l00238"></a>00238 <spanclass="stringliteral">"not owning a mutex"</span>);
<aname="l00239"></a>00239
<aname="l00240"></a>00240 mp = <aclass="code"href="group__mutexes.html#ga705fa60fb8aa28a6632f693e83f78c96"title="Unlocks the next owned mutex in reverse lock order.">chMtxUnlockS</a>();
<aname="l00243"></a>00243 msg = <aclass="code"href="group__scheduler.html#ga306e564f678c1a39139639490c77e78b"title="Puts the current thread to sleep into the specified state with timeout specification.">chSchGoSleepTimeoutS</a>(<aclass="code"href="group__threads.html#ga286c5b1a6459d654d5794fc17e93c939"title="Thread state: Waiting in chCondWait().">THD_STATE_WTCOND</a>, time);
<aname="l00244"></a>00244 <spanclass="keywordflow">if</span> (msg != <aclass="code"href="group__scheduler.html#gaf28d5427eeeb8f737cc7db495157780c"title="Low level message sent to a thread awakened by a timeout.">RDY_TIMEOUT</a>)
<aname="l00245"></a>00245 <aclass="code"href="group__mutexes.html#ga2d6350c2d147d1165c359f30798205f5"title="Locks the specified mutex.">chMtxLockS</a>(mp);
Generated on Sun Nov 28 2010 14:09:48 for ChibiOS/RT by <ahref="http://www.doxygen.org/index.html"><imgsrc="doxygen.png"alt="doxygen"align="middle"border="0"></a> 1.7.1</small></address>