Fanuc C-Executer Operating Manual
B-62443EN-3/03E
- 790 -
2. Synchronization of tasks (semaphore management)
The semaphore is used to synchronize or arbitrate execution of tasks. The
semaphore consists of semaphore counter and semaphore queue. Suspended tasks
which are waiting for the semaphore to be signaled are queued in the semaphore
queue, and when the semaphore is signaled the task at the top of the queue is
awaked to run. Multiple tasks can share a semaphore.
task synchronization task arbitration
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
TASK A TASK B TASK A TASK B
| : | wait for|
| SEM : | get SEM release |
Wait---->* : Wait-----> * <--+ |
: ^ | | ^ | +-- Wait
: +--- Signal | | | :
| : Signal----+ +-------->|
| : | release get |
Following functions are used for semaphore management.
Name Function
---------------+--------------------------------------
os_make_sem create semaphore
os_delt_sem delete semaphore
os_wait_sem wait until semaphore is signaled
os_sign_sem signal the semaphore
* The semaphore is used to synchronize or arbitrate execution of
tasks.
* The semaphore is not exclusively given to a task. ( The system does
not register the task which has gotten the semaphore.) So, the
semaphore can be signaled by even a task that did not get the
semaphore.
* os_make_sem() creates the semaphore.
Initial value of the semaphore counter represents total number of
the tasks which can get semaphore.