##### Synopsis

    #include <ctl_api.h>
    unsigned ctl_wait_semaphore(CTL_SEMAPHORE_t *s,
                                unsigned use_timeout,
                                CTL_TIME_t timeout);

##### Description

The ctl_wait_semaphore waits for the semaphore pointed at by s to be non-zero. If the semaphore is zero then the caller will block unless use_timeout is non-zero and the current time reaches the timeout value. If the timeout occured the function returns zero otherwise it returns one.

##### Restrictions

This function should not be called from an interrupt service routine.

##### Portability

ctl_wait_semaphore is provided in every implementation of the CrossWorks tasking library.

###### See Also

Semaphores