#include <rtl.h>
OS_RESULT os_sem_wait (
OS_IDsemaphore, /* The semaphore to get the token from */
U16 timeout ); /* Length of time to wait for the token */
Description
The os_sem_wait function requests a token from the
semaphore identified by the function argument. If the token
count in the semaphore is more than zero, the function gives a token
to the calling task and decrements the token count in the semaphore.
The calling task might then continue immediately or is put in the
ready list depending on the priorities of other tasks in the ready
list and the value of timeout.
If the token count in the semaphore is zero, the calling task is
put to sleep by the RTX kernel. When a token becomes available in the
semaphore or when the timeout period expires, the RTX kernel wakes
the task and puts it in the ready list .
You can specify any value between 0 and 0xFFFE for the
timeout argument. You must set timeout to 0xFFFF for an
indefinite timeout period.
If you specify a value of 0 for the timeout, the calling
task continues immediately even if there is a higher priority task in
the ready list.
The os_sem_wait function is in the RL-RTX library. The
prototype is defined in rtl.h.
Note
Timeout is measured in number of system intervals.
You must initialize the semaphore object using the
os_sem_init function before you can perform any operation on
the semaphore.
Return Value
The os_sem_wait function returns a completion value:
Return Value
Description
OS_R_SEM
The calling task has waited until a semaphore became
available.
OS_R_TMO
The timeout expired before the token became available.
OS_R_OK
A token was available and the function returned
immediately.
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.