====== OSA : OS_Bsem_Wait_TO ======
**OS_Bsem_Wait_TO (bsem, timeout)**\\
=== ===
{{osa:ref:attr_call_task.png|Allowed only in task}}{{osa:ref:attr_call_ct_sw.png|Switches context}}{{osa:ref:attr_call_to.png|Uses timer}}
Wait for binary semaphore. If timeout expires before semaphore set, then stop waiting with Timeout flag set (see ##[[en:osa:ref:allservices:OS_IsTimeout|OS_IsTimeout]]##)
=== Call allowed: ===
Only in task
=== Parameters: ===
{| class = "fpl"
|-
|//''bsem''//
|Binary semaphore's ID. Number of binary semaphores is set by ##[[en:osa:ref:appendix:configuration#Data contents|OS_BSEMS]]## constant in ##[[en:osa:ref:appendix:configuration|OSAcfg.h]]##
|-
|//''timeout''//
|Time of waiting in system ticks - calling ##[[en:osa:ref:allservices:OS_Timer|OS_Timer]]## periods
|}
=== Returns: ===
{| class = "fpl"
|-
|//''timeout''//
|If timeout expired then system service ##[[en:osa:ref:allservices:OS_IsTimeout|OS_IsTimeout]]## will return **true**
|}
=== Example: ===
void Task (void)
{
for (;;) {
/*...*/
OS_Bsem_Wait_TO(5, 20); // 20 ticks wait for binary semaphore #5
if (!OS_IsTimeout()) {
//
/*...*/
}
/*...*/
}
}
=== Old style name ===
**OS_WaitBSemTimeout**\\
=== See also ===
* [[en:osa:ref:allservices:OS_Bsem_Set|OS_Bsem_Set]]
* [[en:osa:ref:allservices:OS_Bsem_Reset|OS_Bsem_Reset]]
* [[en:osa:ref:allservices:OS_Bsem_Check|OS_Bsem_Check]]
* [[en:osa:ref:allservices:OS_Bsem_Switch|OS_Bsem_Switch]]
* [[en:osa:ref:allservices:OS_Bsem_Wait|OS_Bsem_Wait]]
----
* [[en:osa:ref:services:alphabetical|Alphabetical]]
* [[en:osa:ref:services:brieflist|All services]]
~~UP~~