The synchronization protocol and task purge
If one of the tasks is to be purged, it is task A, because task A is the one suspended. In this case, execution of task A after the failed SUSPEND would be in parallel with task B; the proper serialization would be lost. If the program remained unchanged, Process request and Set results would be taking place at the same time as Get results, with unpredictable results.
Alternative approach to task purge
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. It might 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, task B is left with the responsibility of cleaning up for both tasks.


The difference is that Set results and Get results are replaced by Clean up. It is vital that only these two sequences can happen; this means that both programs must be coded correctly. CICS® ensures that both tasks are told either that SUSPEND and RESUME processing worked, or that it failed.
Program for Task A Program for Task B
SET PARAMETERS;
RESUME B; GET PARAMETERS;
SUSPEND A; PROCESS REQUEST;
RESUME A;
if if
RESPONSE = OK RESPONSE ¬= OK
then then
GET RESULTS; CLEAN UP;
endif endif
If both the SUSPEND and RESUME return ‘OK', the example follows the rules for the normal synchronization; processing finishes at Get results. If neither SUSPEND nor RESUME returns ‘OK', the example follows the rules for the task-purge protocol, and processing finishes at Clean up.
The sequence described previously is one method for dealing with the problem of task purge. Using this method, task B does not know, when it is processing the request, whether or not task A has been purged; this means that B must take great care in its use of resources owned by A (in case A has been purged). In some situations, this restriction may cause difficulties.
- A communicates to B that it is no longer available, thus informing B not to use any resources owned by A.
- A performs its own clean-up processing (including issuing the RESUME call for the purged SUSPEND, as required by the dispatcher protocols), and abends.
- B performs its own clean-up processing.