<p>Semaphores are a flexible synchronization primitive, ChibiOS/RT implements semaphores in their "counting semaphores" variant as defined by Edsger Dijkstra plus several enhancements like:</p>
<ul>
<li>Wait operation with timeout.</li>
<li>Reset operation.</li>
<li>Atomic wait+signal operation.</li>
<li>Return message from the wait operation (OK, RESET, TIMEOUT).</li>
</ul>
<p>The binary semaphores variant can be easily implemented using counting semaphores.<br/>
Operations defined for semaphores:</p>
<ul>
<li><b>Signal</b>: The semaphore counter is increased and if the result is non-positive then a waiting thread is removed from the semaphore queue and made ready for execution.</li>
<li><b>Wait</b>: The semaphore counter is decreased and if the result becomes negative the thread is queued in the semaphore and suspended.</li>
<li><b>Reset</b>: The semaphore counter is reset to a non-negative value and all the threads in the queue are released.</li>
</ul>
<p>Semaphores can be used as guards for mutual exclusion zones (note that mutexes are recommended for this kind of use) but also have other uses, queues guards and counters as example.<br/>
Semaphores usually use a FIFO queuing strategy but it is possible to make them order threads by priority by enabling <code>CH_USE_SEMAPHORES_PRIORITY</code> in <code><aclass="el"href="chconf_8h.html"title="Configuration file template.">chconf.h</a></code>.<br/>
In order to use the Semaphores APIs the <code>CH_USE_SEMAPHORES</code> option must be enabled in <code><aclass="el"href="chconf_8h.html"title="Configuration file template.">chconf.h</a></code>. </p>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Data part of a static semaphore initializer. <ahref="#ga1100c867cc8bd8328f7a7db5e7c74f6d"></a><br/></td></tr>
<tr><tdclass="memItemLeft"align="right"valign="top">#define </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="group__semaphores.html#gac09ac6a24cd3dbe91ac13d72bebf67c1">SEMAPHORE_DECL</a>(name, n) <aclass="el"href="struct_semaphore.html">Semaphore</a> name = _SEMAPHORE_DATA(name, n)</td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Decreases the semaphore counter. <ahref="#ga748b56bc2be187e316496d7b6e748f89"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Increases the semaphore counter. <ahref="#gacb89a28bd1fff2704207423f350215ba"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the semaphore counter current value. <ahref="#gadab3ccf8a34988ef6d410354b2648327"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Initializes a semaphore with the specified counter value. <ahref="#gafe8fc6155a871074e8017efd908b2c58"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Performs a reset operation on the semaphore. <ahref="#ga58e266e609cfd3dbc67f299b3ae9debb"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Performs a reset operation on the semaphore. <ahref="#gae7972b6b22b80ac09bac5a186277ab81"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Performs a wait operation on a semaphore. <ahref="#gabc8f7e509870e9b0527a6a68fad71425"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Performs a wait operation on a semaphore. <ahref="#gaa2c0367078533e291d2e889e251d8b67"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Performs a wait operation on a semaphore with timeout specification. <ahref="#ga0bc227311e5be3e3b6e3aee6a68169da"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Performs a wait operation on a semaphore with timeout specification. <ahref="#ga924ec5d191bb8debe8727ae4dd5d6d03"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Performs a signal operation on a semaphore. <ahref="#ga7ec0cbda23e49e2370e0b91f20baf05e"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Performs a signal operation on a semaphore. <ahref="#gaca0b70cf495a9cb7569e1cf5b07e2b3d"></a><br/></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Performs atomic signal and wait operations on two semaphores. <ahref="#ga0dc7b4339506de346d67b4560b271e44"></a><br/></td></tr>
<p>Data part of a static semaphore initializer. </p>
<p>This macro should be used when statically initializing a semaphore that is part of a bigger structure.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>name</em> </td><td>the name of the semaphore variable </td></tr>
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>n</em> </td><td>the counter initial value, this value must be non-negative </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8h_source.html#l00077">77</a> of file <aclass="el"href="chsem_8h_source.html">chsem.h</a>.</p>
<p>Statically initialized semaphores require no explicit initialization using <code><aclass="el"href="group__semaphores.html#gafe8fc6155a871074e8017efd908b2c58"title="Initializes a semaphore with the specified counter value.">chSemInit()</a></code>.</p>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>name</em> </td><td>the name of the semaphore variable </td></tr>
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>n</em> </td><td>the counter initial value, this value must be non-negative </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8h_source.html#l00088">88</a> of file <aclass="el"href="chsem_8h_source.html">chsem.h</a>.</p>
<p>This macro can be used when the counter is known to be positive. </p>
<p>Definition at line <aclass="el"href="chsem_8h_source.html#l00094">94</a> of file <aclass="el"href="chsem_8h_source.html">chsem.h</a>.</p>
<p>Referenced by <aclass="el"href="group__io__queues.html#gaddf6fc39af7d905c9f23afde14d8d764">chIQReadTimeout()</a>, and <aclass="el"href="group__io__queues.html#ga1e90d41fa021107d72b1bed81186aae8">chOQWriteTimeout()</a>.</p>
<p>Initializes a semaphore with the specified counter value. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[out]</tt> </td><tdvalign="top"><em>sp</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure </td></tr>
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>n</em> </td><td>initial value of the semaphore counter. Must be non-negative. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8c_source.html#l00083">83</a> of file <aclass="el"href="chsem_8c_source.html">chsem.c</a>.</p>
<p>References <aclass="el"href="group__debug.html#ga6bb6c0f97caab3a66332c8bfbf7a3844">chDbgCheck</a>, <aclass="el"href="group__internals.html#ga6d19d0f3ff1fa599b6d9783dec180451">queue_init</a>, <aclass="el"href="struct_semaphore.html#ae42955cd2346167681e0fd6a136369cd">Semaphore::s_cnt</a>, and <aclass="el"href="struct_semaphore.html#a26051a38c22dc11a7a2bf37496d8e906">Semaphore::s_queue</a>.</p>
<p>Referenced by <aclass="el"href="group___a_d_c.html#gac7f619e304c79c17f19221d05138d405">adcObjectInit()</a>, <aclass="el"href="group___c_a_n.html#gadf8c892ca4bd2544d03be8a690885aef">canObjectInit()</a>, <aclass="el"href="group__heaps.html#ga7135c9ddbd1402a4a36ce44df948f4e4">chHeapInit()</a>, <aclass="el"href="group__io__queues.html#ga0d3a250e6572526b165d2c61f69230e5">chIQInit()</a>, <aclass="el"href="group__mailboxes.html#gaff65b97bfdbf9144e9727a100a9be93a">chMBInit()</a>, <aclass="el"href="group__io__queues.html#gae2a5a0ef7c488ac02762e76933baa7b1">chOQInit()</a>, <aclass="el"href="group__heaps.html#ga7e7a6625a49b6a560a47ae7575575264">heap_init()</a>, <aclass="el"href="group___m_a_c.html#ga34d60b00ad9794d52da6833e18c9ec70">macObjectInit()</a>, <aclass="el"href="classchibios__rt_1_1_semaphore.html#a0804607c066a7a373188cb8220203f8f">chibios_rt::Semaphore::Semaphore()</a>, and <aclass="el"href="group___s_p_i.html#ga87a7bdc554b8e8fdfc77064e67689fcf">spiObjectInit()</a>.</p>
<p>Performs a reset operation on the semaphore. </p>
<dlclass="note"><dt><b>Note:</b></dt><dd>The released threads can recognize they were waked up by a reset rather than a signal because the <code><aclass="el"href="group__semaphores.html#gabc8f7e509870e9b0527a6a68fad71425"title="Performs a wait operation on a semaphore.">chSemWait()</a></code> will return <code>RDY_RESET</code> instead of <code>RDY_OK</code>.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>sp</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure </td></tr>
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>n</em> </td><td>the new value of the semaphore counter. The value must be non-negative. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8c_source.html#l00101">101</a> of file <aclass="el"href="chsem_8c_source.html">chsem.c</a>.</p>
<p>References <aclass="el"href="group__scheduler.html#ga4e38b4bee3d2330f6a0f1cdb7660af20">chSchRescheduleS()</a>, <aclass="el"href="group__semaphores.html#gae7972b6b22b80ac09bac5a186277ab81">chSemResetI()</a>, <aclass="el"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, and <aclass="el"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>.</p>
<p>Referenced by <aclass="el"href="classchibios__rt_1_1_semaphore.html#aecb934714ebe5658c857ef1021dd5f2b">chibios_rt::Semaphore::Reset()</a>.</p>
<areashape="rect"id="node3"href="group__scheduler.html#ga4e38b4bee3d2330f6a0f1cdb7660af20"title="Performs a reschedule if a higher priority thread is runnable."alt=""coords="136,5,253,32"/><areashape="rect"id="node9"href="group__semaphores.html#gae7972b6b22b80ac09bac5a186277ab81"title="Performs a reset operation on the semaphore."alt=""coords="152,56,237,83"/><areashape="rect"id="node5"href="group__scheduler.html#ga0257cf203e72a766a52059750cb97e6e"title="Switches to the first thread on the runnable queue."alt=""coords="301,5,427,32"/><areashape="rect"id="node7"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List."alt=""coords="476,31,561,57"/><areashape="rect"id="node12"href="group__internals.html#gacacfe77140cab62948e63d898bf4dfba"title="Removes the last-out Thread from a queue and returns it."alt=""coords="325,107,403,133"/></map>
<p>Performs a reset operation on the semaphore. </p>
<dlclass="note"><dt><b>Note:</b></dt><dd>The released threads can recognize they were waked up by a reset rather than a signal because the <code><aclass="el"href="group__semaphores.html#gabc8f7e509870e9b0527a6a68fad71425"title="Performs a wait operation on a semaphore.">chSemWait()</a></code> will return <code>RDY_RESET</code> instead of <code>RDY_OK</code>. </dd>
<dd>
This function does not reschedule.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>sp</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure </td></tr>
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>n</em> </td><td>the new value of the semaphore counter. The value must be non-negative. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8c_source.html#l00120">120</a> of file <aclass="el"href="chsem_8c_source.html">chsem.c</a>.</p>
<p>Referenced by <aclass="el"href="group___a_d_c.html#gabce14d8f240e85715cded02c85b6585a">adcStopConversion()</a>, <aclass="el"href="group___c_a_n.html#ga4e89a7d246119e077d27431a02586133">canStop()</a>, <aclass="el"href="group___s_t_m32___a_d_c.html#ga727ca25370379b53e77a820e7bfee540">CH_IRQ_HANDLER()</a>, <aclass="el"href="group__io__queues.html#ga2252ca3e5d6ee6d8d323d025365aee59">chIQResetI()</a>, <aclass="el"href="group__mailboxes.html#ga4199e224456395c3dbc74dbc889dff94">chMBReset()</a>, <aclass="el"href="group__io__queues.html#ga0a35a7de945e4b56b5fb5f5c8567e296">chOQResetI()</a>, and <aclass="el"href="group__semaphores.html#ga58e266e609cfd3dbc67f299b3ae9debb">chSemReset()</a>.</p>
<areashape="rect"id="node3"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List."alt=""coords="140,5,225,32"/><areashape="rect"id="node5"href="group__internals.html#gacacfe77140cab62948e63d898bf4dfba"title="Removes the last-out Thread from a queue and returns it."alt=""coords="144,56,221,83"/></map>
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>sp</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure </td></tr>
</table>
</dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_OK</em> </td><td>if the semaphore was signaled or not taken. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_RESET</em> </td><td>if the semaphore was reset using <code><aclass="el"href="group__semaphores.html#ga58e266e609cfd3dbc67f299b3ae9debb"title="Performs a reset operation on the semaphore.">chSemReset()</a></code>. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8c_source.html#l00138">138</a> of file <aclass="el"href="chsem_8c_source.html">chsem.c</a>.</p>
<p>References <aclass="el"href="group__semaphores.html#gaa2c0367078533e291d2e889e251d8b67">chSemWaitS()</a>, <aclass="el"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, and <aclass="el"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>.</p>
<p>Referenced by <aclass="el"href="group___s_p_i.html#ga803cec73f6dd8d3d1f18fb6a61b8255a">spiAcquireBus()</a>, and <aclass="el"href="classchibios__rt_1_1_semaphore.html#abfb1b068e95063f490b27cc3b467f63f">chibios_rt::Semaphore::Wait()</a>.</p>
<areashape="rect"id="node3"href="group__semaphores.html#gaa2c0367078533e291d2e889e251d8b67"title="Performs a wait operation on a semaphore."alt=""coords="131,5,213,32"/><areashape="rect"id="node5"href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986"title="Puts the current thread to sleep into the specified state."alt=""coords="261,5,363,32"/></map>
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>sp</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure </td></tr>
</table>
</dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_OK</em> </td><td>if the semaphore was signaled or not taken. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_RESET</em> </td><td>if the semaphore was reset using <code><aclass="el"href="group__semaphores.html#ga58e266e609cfd3dbc67f299b3ae9debb"title="Performs a reset operation on the semaphore.">chSemReset()</a></code>. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8c_source.html#l00154">154</a> of file <aclass="el"href="chsem_8c_source.html">chsem.c</a>.</p>
<areashape="rect"id="node3"href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986"title="Puts the current thread to sleep into the specified state."alt=""coords="136,31,237,57"/><areashape="rect"id="node5"href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7"title="Inserts in the circular debug trace buffer a context switch record."alt=""coords="287,5,367,32"/><areashape="rect"id="node7"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it."alt=""coords="287,56,367,83"/></map>
<p>Performs a wait operation on a semaphore with timeout specification. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>sp</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure </td></tr>
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>time</em> </td><td>the number of ticks before the operation timeouts, the following special values are allowed:</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_OK</em> </td><td>if the semaphore was signaled or not taken. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_RESET</em> </td><td>if the semaphore was reset using <code><aclass="el"href="group__semaphores.html#ga58e266e609cfd3dbc67f299b3ae9debb"title="Performs a reset operation on the semaphore.">chSemReset()</a></code>. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_TIMEOUT</em> </td><td>if the semaphore was not signaled or reset within the specified timeout. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8c_source.html#l00181">181</a> of file <aclass="el"href="chsem_8c_source.html">chsem.c</a>.</p>
<p>References <aclass="el"href="group__semaphores.html#ga924ec5d191bb8debe8727ae4dd5d6d03">chSemWaitTimeoutS()</a>, <aclass="el"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, and <aclass="el"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>.</p>
<p>Referenced by <aclass="el"href="classchibios__rt_1_1_semaphore.html#a589b4780f60d73929bd77a652b526868">chibios_rt::Semaphore::WaitTimeout()</a>.</p>
<areashape="rect"id="node3"href="group__semaphores.html#ga924ec5d191bb8debe8727ae4dd5d6d03"title="Performs a wait operation on a semaphore with timeout specification."alt=""coords="168,5,288,32"/><areashape="rect"id="node5"href="group__scheduler.html#ga306e564f678c1a39139639490c77e78b"title="Puts the current thread to sleep into the specified state with timeout specification."alt=""coords="336,5,475,32"/></map>
<p>Performs a wait operation on a semaphore with timeout specification. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>sp</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure </td></tr>
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>time</em> </td><td>the number of ticks before the operation timeouts, the following special values are allowed:</p>
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_OK</em> </td><td>if the semaphore was signaled or not taken. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_RESET</em> </td><td>if the semaphore was reset using <code><aclass="el"href="group__semaphores.html#ga58e266e609cfd3dbc67f299b3ae9debb"title="Performs a reset operation on the semaphore.">chSemReset()</a></code>. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_TIMEOUT</em> </td><td>if the semaphore was not signaled or reset within the specified timeout. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8c_source.html#l00204">204</a> of file <aclass="el"href="chsem_8c_source.html">chsem.c</a>.</p>
<areashape="rect"id="node3"href="group__scheduler.html#ga306e564f678c1a39139639490c77e78b"title="Puts the current thread to sleep into the specified state with timeout specification."alt=""coords="173,56,312,83"/><areashape="rect"id="node5"href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986"title="Puts the current thread to sleep into the specified state."alt=""coords="360,5,461,32"/><areashape="rect"id="node7"href="group__time.html#ga680d851a74e594cc965101e79891840f"title="Disables a Virtual Timer."alt=""coords="372,56,449,83"/><areashape="rect"id="node9"href="group__time.html#ga1c44c3a0bc64b2954d95cd98b2e7124e"title="Enables a virtual timer."alt=""coords="377,107,444,133"/></map>
<p>Performs a signal operation on a semaphore. </p>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>sp</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8c_source.html#l00225">225</a> of file <aclass="el"href="chsem_8c_source.html">chsem.c</a>.</p>
<p>References <aclass="el"href="group__debug.html#ga6bb6c0f97caab3a66332c8bfbf7a3844">chDbgCheck</a>, <aclass="el"href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95">chSchWakeupS()</a>, <aclass="el"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42">chSysLock</a>, <aclass="el"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e">chSysUnlock</a>, <aclass="el"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a">fifo_remove()</a>, <aclass="el"href="group__scheduler.html#gae1c86078318e11c2fa57ee3c2ec69f61">RDY_OK</a>, <aclass="el"href="struct_semaphore.html#ae42955cd2346167681e0fd6a136369cd">Semaphore::s_cnt</a>, and <aclass="el"href="struct_semaphore.html#a26051a38c22dc11a7a2bf37496d8e906">Semaphore::s_queue</a>.</p>
<p>Referenced by <aclass="el"href="classchibios__rt_1_1_semaphore.html#a202630db53afefbe5c419ee6d2eddab1">chibios_rt::Semaphore::Signal()</a>, and <aclass="el"href="group___s_p_i.html#ga1b04a2410ef4323ee4e37c63f320c18f">spiReleaseBus()</a>.</p>
<areashape="rect"id="node3"href="group__scheduler.html#gae47a8819a21ef2d521124e76bfb37c95"title="Wakes up a thread."alt=""coords="139,31,237,57"/><areashape="rect"id="node9"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it."alt=""coords="148,81,228,108"/><areashape="rect"id="node5"href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7"title="Inserts in the circular debug trace buffer a context switch record."alt=""coords="289,5,369,32"/><areashape="rect"id="node7"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List."alt=""coords="287,56,372,83"/></map>
<p>Performs a signal operation on a semaphore. </p>
<dlclass="note"><dt><b>Note:</b></dt><dd>This function does not reschedule.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>sp</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8c_source.html#l00241">241</a> of file <aclass="el"href="chsem_8c_source.html">chsem.c</a>.</p>
<p>Referenced by <aclass="el"href="group__io__queues.html#ga23b72ba9803de5a20caa84ffd0c193fc">chIQPutI()</a>, <aclass="el"href="group__mailboxes.html#gadc562242a8854497a1f9539cb9ffea09">chMBFetchS()</a>, <aclass="el"href="group__mailboxes.html#gaa9c91c0b781bec0df3540407d75b1bb3">chMBPostAheadS()</a>, <aclass="el"href="group__mailboxes.html#gac6514c185ae87c2633132478ea48d689">chMBPostS()</a>, and <aclass="el"href="group__io__queues.html#ga34a5a71f39e94fcfdd88935da92a8ce9">chOQGetI()</a>.</p>
<areashape="rect"id="node3"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List."alt=""coords="143,5,228,32"/><areashape="rect"id="node5"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it."alt=""coords="145,56,225,83"/></map>
<p>Performs atomic signal and wait operations on two semaphores. </p>
<dlclass="note"><dt><b>Note:</b></dt><dd>The function is available only if the <code>CH_USE_SEMSW</code> option is enabled in <code><aclass="el"href="chconf_8h.html"title="Configuration file template.">chconf.h</a></code>.</dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>sps</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure to be signaled </td></tr>
<tr><tdvalign="top"><tt>[in]</tt> </td><tdvalign="top"><em>spw</em> </td><td>pointer to a <code><aclass="el"href="struct_semaphore.html"title="Semaphore structure.">Semaphore</a></code> structure to be wait on </td></tr>
</table>
</dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_OK</em> </td><td>if the semaphore was signaled or not taken. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>RDY_RESET</em> </td><td>if the semaphore was reset using <code><aclass="el"href="group__semaphores.html#ga58e266e609cfd3dbc67f299b3ae9debb"title="Performs a reset operation on the semaphore.">chSemReset()</a></code>. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <aclass="el"href="chsem_8c_source.html#l00265">265</a> of file <aclass="el"href="chsem_8c_source.html">chsem.c</a>.</p>
<areashape="rect"id="node3"href="group__scheduler.html#ga97c1c514b755a1e71caf2f19c1ccf986"title="Puts the current thread to sleep into the specified state."alt=""coords="337,26,439,53"/><areashape="rect"id="node7"href="group__internals.html#ga042479f09357fc59befebf4dfe0e9f4a"title="Removes the first-out Thread from a queue and returns it."alt=""coords="503,26,583,53"/><areashape="rect"id="node9"href="group__scheduler.html#ga535d58cfb3436c8d4e4586c31c062298"title="Inserts a thread in the Ready List."alt=""coords="500,128,585,154"/><areashape="rect"id="node11"href="group__scheduler.html#ga4e38b4bee3d2330f6a0f1cdb7660af20"title="Performs a reschedule if a higher priority thread is runnable."alt=""coords="160,77,277,104"/><areashape="rect"id="node5"href="group__debug.html#gac7f8f0653faf2e3a93108ff5333821b7"title="Inserts in the circular debug trace buffer a context switch record."alt=""coords="503,77,583,104"/><areashape="rect"id="node13"href="group__scheduler.html#ga0257cf203e72a766a52059750cb97e6e"title="Switches to the first thread on the runnable queue."alt=""coords="325,77,451,104"/></map>
Generated on Sun Nov 28 2010 14:09:56 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>