<divclass="title">Signal Events<divclass="ingroups"><aclass="el"href="group__CMSIS__RTOS__InterThread.html">Inter-Thread Communication and Resource Sharing</a></div></div></div>
<trclass="memdesc:ga01edde265710d883b6e237d34a6ef4a6"><tdclass="mdescLeft"> </td><tdclass="mdescRight">maximum number of Signal Flags available per thread <ahref="#ga01edde265710d883b6e237d34a6ef4a6">More...</a><br/></td></tr>
<trclass="memdesc:ga3de2730654589d6c3559c4b9e2825553"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Set the specified Signal Flags of an active thread. <ahref="#ga3de2730654589d6c3559c4b9e2825553">More...</a><br/></td></tr>
<trclass="memdesc:ga87283a6ebc31ce9ed42baf3ea7e4eab6"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Clear the specified Signal Flags of an active thread. <ahref="#ga87283a6ebc31ce9ed42baf3ea7e4eab6">More...</a><br/></td></tr>
<trclass="memdesc:ga38860acda96df47da6923348d96fc4c9"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Wait for one or more Signal Flags to become signaled for the current <b>RUNNING</b> thread. <ahref="#ga38860acda96df47da6923348d96fc4c9">More...</a><br/></td></tr>
<p>Signals are used to trigger execution states between threads. The signal management functions in CMSIS-RTOS allow you to control or wait for signal flags. Each thread has up to 31 assigned signal flags. The maximum number of signal flags is defined in the <aclass="el"href="cmsis__os_8h.html">cmsis_os.h</a> file (<b>#define osFeature_Signals</b>).</p>
<li>can wait for signals to be set (using <aclass="el"href="group__CMSIS__RTOS__SignalMgmt.html#ga38860acda96df47da6923348d96fc4c9">osSignalWait</a>). Using this function, it enters the <aclass="el"href="group__CMSIS__RTOS__ThreadMgmt.html#ThreadStates">WAITING</a> state. The <aclass="el"href="group__CMSIS__RTOS__SignalMgmt.html#ga38860acda96df47da6923348d96fc4c9">osSignalWait</a> parameter <em>signals</em> defines the signals that are required to put the thread back into <b>READY</b> state.</li>
<li>may set one or more flags in any other given thread (using <aclass="el"href="group__CMSIS__RTOS__SignalMgmt.html#ga3de2730654589d6c3559c4b9e2825553">osSignalSet</a>).</li>
<li>may clear its own signals or the signals of other threads (using <aclass="el"href="group__CMSIS__RTOS__SignalMgmt.html#ga87283a6ebc31ce9ed42baf3ea7e4eab6">osSignalClear</a>).</li>
<li>In the thread (for example thread ID <code>tid_thread1</code>) that is supposed to wait for a signal, call the wait function: <divclass="fragment"><divclass="line"><aclass="code"href="group__CMSIS__RTOS__SignalMgmt.html#ga38860acda96df47da6923348d96fc4c9">osSignalWait</a> (0x0001, <aclass="code"href="cmsis__os_8h.html#a9eb9a7a797a42e4b55eb171ecc609ddb">osWaitForever</a>); <spanclass="comment">// wait forever for the signal 0x0001</span></div>
<li>In another thread (or threads) that are supposed to wake the waiting thread up call: <divclass="fragment"><divclass="line"><aclass="code"href="group__CMSIS__RTOS__SignalMgmt.html#ga3de2730654589d6c3559c4b9e2825553">osSignalSet</a> (tid_thread1, 0x0001); <spanclass="comment">// set the signal 0x0001 for thread tid_thread1</span></div>
<divclass="line"><aclass="code"href="group__CMSIS__RTOS__Wait.html#ga02e19d5e723bfb06ba9324d625162255">osDelay</a> (1000); <spanclass="comment">// wait for 1 second</span></div>
<p>The CMSIS-RTOS API may support a variable number of signal flags. This define specifies the number of signal flags available per thread. The maximum value is 32 signal flags per thread.</p>
<p><aclass="el"href="rtxImplementation.html">CMSIS-RTOS RTX</a> Setting: <b>osFeature_Signals</b> is 16 </p>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">thread_id</td><td>thread ID obtained by <aclass="el"href="group__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> or <aclass="el"href="group__CMSIS__RTOS__ThreadMgmt.html#gab1df2a28925862ef8f9cf4e1c995c5a7">osThreadGetId</a>. </td></tr>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">signals</td><td>specifies the signal flags of the thread that shall be cleared. </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters or call from ISR. </dd></dl>
<dlclass="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osSignalClear</b> shall be consistent in every CMSIS-RTOS.</dd></dl>
<p>Clear the signal flags of an active thread.</p>
<dlclass="section note"><dt>Note</dt><dd>Cannot be called from <aclass="el"href="functionOverview.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">thread_id</td><td>thread ID obtained by <aclass="el"href="group__CMSIS__RTOS__ThreadMgmt.html#gac59b5713cb083702dce759c73fd90dff">osThreadCreate</a> or <aclass="el"href="group__CMSIS__RTOS__ThreadMgmt.html#gab1df2a28925862ef8f9cf4e1c995c5a7">osThreadGetId</a>. </td></tr>
<dlclass="section note"><dt>Note</dt><dd><aclass="el"href="functionOverview.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a> can call this function.</dd></dl>
<divclass="line"> signals = <aclass="code"href="group__CMSIS__RTOS__SignalMgmt.html#ga3de2730654589d6c3559c4b9e2825553">osSignalSet</a> (thread_id, 0x00000005); <spanclass="comment">// Send signals to the created thread</span></div>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">signals</td><td>wait until all specified signal flags set or 0 for any single signal flag. </td></tr>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">millisec</td><td><aclass="el"href="functionOverview.html#CMSIS_RTOS_TimeOutValue">Timout Value</a> or 0 in case of no time-out. </td></tr>
<dlclass="section return"><dt>Returns</dt><dd>event flag information or error code. </dd></dl>
<dlclass="section note"><dt>Note</dt><dd>MUST REMAIN UNCHANGED: <b>osSignalWait</b> shall be consistent in every CMSIS-RTOS.</dd></dl>
<p>Suspend the execution of the current <b>RUNNING</b> thread until all specified signal flags with the parameter <em>signals</em> are set. When the parameter <em>signals</em> is 0 the current <b>RUNNING</b> thread is suspended until any signal is set. When these signal flags are already set, the function returns instantly. Otherwise the thread is put into the state <b>WAITING</b>. Signal flags that are reported as event are automatically cleared.</p>
<p>The argument <em>millisec</em> specifies how long the system waits for the specified signal flags. While the system waits the thread calling this function is put into the state <b>WAITING</b>. The timeout value can have the following values:</p>
<li><em>osErrorISR:</em><aclass="el"href="group__CMSIS__RTOS__SignalMgmt.html#ga38860acda96df47da6923348d96fc4c9">osSignalWait</a> cannot be called from interrupt service routines.</li>
<dlclass="section note"><dt>Note</dt><dd>Cannot be called from <aclass="el"href="functionOverview.html#CMSIS_RTOS_ISR_Calls">Interrupt Service Routines</a>.</dd></dl>