Fanuc C-Executer Operating Manual
B-62443EN-3/03E
- 791 -
Waiting for signal
~~~~~~~~~~~~~~~~~~
* os_wait_sem() decrements the semaphore counter, and suspends the
execution of the calling task if the value of the semaphore counter
is negative.
sem-- ==> decrement semaphore counter
if( sem < 0 ) ==> if negative counter value
Wait ==> queue the task into the semaphore
queue and suspend execution
operation semaphore counter semaphore queue
------------+-----------------+-------------------------
1 none
Wait 0 none
Wait -1 ==> ----X
Wait -2 ==> ----O----X
Wait -3 ==> ----O----O----X
Signaling semaphore
~~~~~~~~~~~~~~~~~~~
* os_sign_sem() signals the semaphore.
* If there are any suspended tasks, the task at the top of the
semaphore queue is awaked to run.
sem++ ==> increment semaphore counter
if( sem <= 0 ) ==> if counter value is 0 or negative
Ready ==> awake the task at the top of the
semaphore queue
operation semaphore counter semaphore queue
----------+------------------+-------------------------
-3 ==> ----O----O----X
Signal -2 ==> ----O----X
Signal -1 ==> ----X
Signal 0 none
Signal 1 none