OSA : OS_Csem_Wait_TO

OS_Csem_Wait_TO (csem, timeout)

Allowed only in taskSwitches contextUses timer

Wait for counting semaphore. If timeout expires before this event occurs, then stop waiting with Timeout flag set (see OS_IsTimeout)

OS_ENABLE_CSEM constant must be defined in OSAcfg.h. Size of counting semaphores is defined by OS_CSEM_SIZE constant

For PIC16, counting semaphores can only be allocated in bank0 or bank1

Call allowed:

Only in task

Parameters:

csem Counting semaphore. Variable of OST_CSEM type
timeout Time of waiting in system ticks - calling OS_Timer periods

Returns:

timeout If timeout expired then system service 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