
2. TASK CONTROL FUNCTION
B–61863E–1/06
PMC CONTROL SOFTWARE
64
“Example of synchronous control with counter type semaphores”
Suppose that a task is waiting until processing of another task is
completed. In this example, task A is assumed to wait until
processing of task B is completed, and task B is assumed to wait until
processing of task C is completed.
This operation can be controlled by using two semaphores as shown
below:
* In the following operation, assume that A has the highest priority
among the three tasks and that C has the lowest. (Control is
possible even when priorities are undetermined.)
Wait D
TASK A TASK B TASK C SEM D SEM E
Wait E
processing
Signal E
Signal D
processing
0
0
–1
–1
processing
00
“Example of intertask communication with counter type
semaphores”
The following example explains how data is passed between tasks
using a ring buffer.
Let a task writing data in the buffer be task A, and a task reading the
written data be task B.
In the example, assume that data not yet read cannot be overwritten
and that data not yet written cannot be read.
This operation is controlled by using two counter type semaphores as
shown below:
SEM C
Buffer (shared memory)
SEM D
TASK A
Wait Signal
TASK B
Wait Signal
Read
Write