- 104 -
[
[
[
[
F
F
u
u
n
n
c
c
t
t
i
i
o
o
n
n
a
a
l
l
d
d
e
e
s
s
c
c
r
r
i
i
p
p
t
t
i
i
o
o
n
n
]
]
]
]
This service call acquires one semaphore resource from the semaphore indicated by semid.
If the semaphore resource count is equal to or greater than 1, the semaphore resource count is decremented by 1, and the
service call issuing task continues execution. On the other hand, if the semaphore count value is 0, the wai_sem or
twai_sem service call invoking task is enqueued in a waiting queue for that semaphore. If the attribute of the semaphore
semid is TA_TFIFO, the task is enqueued in order of FIFO; if TA_TPRI, the task is enqueued in order of priority. For the
pol_sem and ipol_sem service calls, the task returns immediately and responds to the call with the error code E_TMOUT.
For the twai_sem service call, specify a wait time for tmout in ms units. The values specified for tmout must be within
(0x7FFFFFFF-time tick value). If any value exceeding this limit is specified, operation of the service call cannot be guar-
anteed. If TMO_POL=0 is specified for tmout, it means specifying 0 as a timeout value, in which case the service call op-
erates the same way as pol_sem. Furthermore, if specified as tmout=TMO_FEVR(–1), it means specifying an infinite wait,
in which case the service call operates the same way as wai_sem.
The task placed into WAITING state by execution of the wai_sem or twai_sem service call is released from the WAITING
state in the following cases:
When the sig_sem or isig_sem service call is issued before the tmout time elapses, with
task-awaking conditions thereby satisfied
The error code returned in this case is E_OK.
When the first time tick occurred after tmout elapsed while task-awaking conditions remain un-
satisfied
The error code returned in this case is E_TMOUT.
When the task is forcibly released from WAITING state by the rel_wai or irel_wai service call is-
sued from another task or a handler
The error code returned in this case is E_RLWAI.
If this service call is to be issued from task context, use wai_sem, twai_sem, or pol_sem; ; if issued from non-task context,
use ipol_sem.