
B–61863E–1/06
2. TASK CONTROL FUNCTION
PMC CONTROL SOFTWARE
65
TASK A TASK B SEM C SEM D
3 0
Signal D –1
Wait C (Wait) 2
Write
Signal D 0
Read
Wait C (Ready) 1
Write
Signal D 1
Wait C 0
Write
Signal D 2
Wait C –1
Signal C 0
Initial value of semaphore C All buffer areas
Semaphore C Positive : Available areas in the buffer
Negative : Number of tasks waiting for data write
Semaphore D Positive : Buffer areas containing data
Negative : Number of tasks waiting for data read)
NOTE
This control can also be enabled using a mailbox
(mentioned later).
(2) Exclusive control type semaphores
Exclusive control type semaphores are generally used as flags to post
the ownership of a resource. Resources whose ownership is to be
posted by a semaphore are resources that can be used successively.
These resources include devices that can be used by one task at a time,
such as files and external devices.
The ownership of the exclusive control type semaphore conceptually
means that only the task acquiring the ownership can acquire its
semaphore. A task waiting for the semaphore must wait until the task
having the ownership relinquishes the semaphore.
The exclusive control type semaphore has a special feature.It permits
the task priority to be changed at the time of semaphore acquisition.
When a semaphore is created, an owner priority is specified. If a task
acquiring the semaphore has a lower priority than the specified owner
priority, the task’s priority is increased to the specified level. Then,
when the task releases the ownership, the priority of the task is
returned to its original priority.
With this feature, even tasks having low priority can perform
processing associated with semaphore acquisition at a specified
priority. This prevents the system performance from deteriorating.
(Example of task priority for the exclusive control type semaphore)
Assume that the owner priority is set to 10 when a semaphore is
created.
Task E acquires the semaphone. TASK E relinquishes the semaphore.
pri
10
11
12
13
14
15
TASK A
TASK B
TASK C
TASK D
TASK E
Changes
priority to
PRI 10.
TASK E
TASK A
TASK B
TASK C
TASK D
Return
priority to
PRI 15.
pri
10
11
12
13
14
15