The normal synchronization protocol
In the normal case, synchronization involves two tasks and three operations. In the
following sample operations, the tasks are A(the task that requests a service) and
B (the task that processes a request from task A).
1. TaskA starts the request by:
vSetting the parameters to be used by task B
vResuming task B
vIssuing the SUSPEND call.
2. TaskB performs the action by:
vGetting the parameters
vPerforming the action
vSetting the results
vTerminating(or waiting for new work).
3. TaskA ends the interaction by:
vGetting the results left by task B.
This sequence looks like:
Ignoring the Resume and Suspend, the execution amounts to:
where these actions are always sequential.
The synchronization protocol and task purge
If one of the tasks is to be purged, it is task A, because taskA is the one
suspended. In this case, execution of task Aafter the failed SUSPEND would be in
parallel with task B; the proper serialization would be lost. If the program were left
unchanged, Process request and Set results would be taking place at the same
time as Get results, with unpredictable results.
One way of preventing this problem is to ensure that task A, if it is to be purged,
does not do anything that could interfere with task B. (This may well mean that
A must not detach, if doing so releases storage that B needs to access.) Because
the only task that is now involved is task B, B is left with the responsibility of
cleaning up for both tasks.
The sequence is:
Task A: Set parameters Resume task B Suspend Get results
Task B: Get parameters Process request Set results Resume Detach
task A
Set parameters; Get parameters; Process request; Set results; Get results
332 Customization Guide