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.
|