tk_wai_sem
Wait on Semaphore
ER ercd = tk_wai_sem ( ID semid, INT cnt, TMO tmout ) ;
ID semid Semaphore ID
INT cnt Resource request count
TMO tmout timeout
ER ercd Error code
E_OK ormal completion
E_ID Invalid ID number (semid is invalid or cannot be used)
E_NOEXS Object does not exist (the semaphore specified in semid does not exist)
E_PAR Parameter error (tmout < (.2), cnt < 0)
E_DLT The object being waited for was deleted (the specified semaphore was deleted while waiting)
E_RLWAI Wait state released (tk_rel_wai received in wait state)
E_DISWAI Wait released by wait disabled state
E_TMOUT Polling failed or timeout
E_CTX Context error (issued from task-independent portion or in dispatch disabled state)
Gets from the semaphore specified in semid the number of resources indicated in cnt. If the requested resources can be allocated, the task issuing this system call does not enter WAIT state but continues executing. In this case the semaphore count (semcnt) is decreased by the size of cnt. If the resources are not available, the task issuing this system call enters WAIT state, and is put in the queue of tasks waiting for the semaphore. The semaphore count (semcnt) for this semaphore does not change in this case.
A maximum wait time (timeout) can be set in tmout. If the tmout time elapses before the wait release condition is met (tk_sig_sem is not executed), the system call terminates, returning timeout error code E_TMOUT. Only positive values can be set in tmout. The time base for tmout (time unit) is the same as that for system time (= 1 ms).
When TMO_POL = 0 is set in tmout, this means 0 was specified as the timeout value, and E_TMOUT is returned without entering WAIT state even if no resources are acquired.
When TMO_FEVR =(-1) is set in tmout, this means in.nity was specified as the timeout value, and the task continues to wait for resource acquisition without timing out.

Comments