====== OSA : OS_Csem_Wait_TO ======
**OS_Csem_Wait_TO (csem, 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 counting semaphore. If timeout expires before this event occurs, then stop waiting with Timeout flag set (see ##[[en:osa:ref:allservices:OS_IsTimeout|OS_IsTimeout]]##)
##[[en:osa:ref:appendix:configuration|OS_ENABLE_CSEM]]## constant must be defined in ##[[en:osa:ref:appendix:configuration|OSAcfg.h]]##. Size of counting semaphores is defined by ##[[en:osa:ref:appendix:configuration#Data types|OS_CSEM_SIZE]]## constant
For PIC16, counting semaphores can only be allocated in **bank0** or **bank1**
=== Call allowed: ===
Only in task
=== Parameters: ===
{| class = "fpl"
|-
|//''csem''//
|Counting semaphore. Variable of ##[[en:osa:ref:description:data_types#OST_CSEM|OST_CSEM]]## type
|-
|//''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: ===
OST_CSEM csem;
void Task (void)
{
for (;;) {
/*...*/
OS_Csem_Wait_TO (csem, 300); // wait 300 ticks for csem
if (!OS_IsTimeout()) {
//
/*...*/
}
/*...*/
}
}
=== Old style name ===
**OS_WaitCSemTimeout**\\
=== See also ===
* [[en:osa:ref:allservices:OS_Csem_Create|OS_Csem_Create]]
* [[en:osa:ref:allservices:OS_Csem_Signal|OS_Csem_Signal]]
* [[en:osa:ref:allservices:OS_Csem_Set|OS_Csem_Set]]
* [[en:osa:ref:allservices:OS_Csem_SetValue|OS_Csem_SetValue]]
* [[en:osa:ref:allservices:OS_Csem_Reset|OS_Csem_Reset]]
* [[en:osa:ref:allservices:OS_Csem_Accept|OS_Csem_Accept]]
* [[en:osa:ref:allservices:OS_Csem_Check|OS_Csem_Check]]
* [[en:osa:ref:allservices:OS_Csem_Wait|OS_Csem_Wait]]
----
* [[en:osa:ref:services:alphabetical|Alphabetical]]
* [[en:osa:ref:services:brieflist|All services]]
~~UP~~