
B–61863E–1/06
2. TASK CONTROL FUNCTION
PMC CONTROL SOFTWARE
61
Semaphores are used for synchronization and exclusive control between
tasks. A semaphore consists of a signed integer variable (counter) and a
semaphore queue. The semaphore queue holds tasks waiting for the
semaphore signal. When the semaphore is signaled from a task, the top
task in the queue waiting for the semaphore is dequeued.
Intertask synchronization Exclusive control
Task A Task B
SEM
Wait
Signal
SEM
Wait
Task A Task B
Wait
Signal
Wait for
relinquishment
Relinquish Acquire
Acquire
Two types of semaphores are supported: Counter type and exclusive
control type.
The counter type semaphore is controlled by the counter value of the
semaphore. The exclusive control type is controlled by the ownership.
[Counter type semaphores]
D Tasks can acquire the same semaphore.
D Are used for synchronous control and exclusive control.
[Exclusive control type semaphores]
D One semaphore can be owned by only one task.
D When a task acquires a semaphore, its priority can be increased
temporarily until the task relinquishes the semaphore.
D Are used for exclusive control only.
Signed counter
Counter type semaphore Exclusive control type semaphore
Ownership
TASKA TASKB TASKA TASKB
For semaphore control, the following system calls are used:
Function name Description
os_make_sem Creates a counter type semaphore.
os_mak2_sem Creates an exclusive control type semaphore.
os_delt_sem Deletes a semaphore.
os_wait_sem Waits for a semaphore signal.
os_sign_sem Signals a semaphore.
os_queu_sem Changes the queue type of a semaphore.
2.6.3
Intertask
Synchronization
(Semaphore Control)