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 sequence is shown in the following diagram:
The picture shows the sequence described in the preceding text. The sequence for Task A is: set parameters; resume Task B; suspend-fail. The sequence for Task B is: get parameters; process request; resume-fail; clean up both.
Because task-purging is effective only if performed between SUSPEND and RESUME, Suspend-fail precedes Resume-fail. With the same constraints on serialization as in the normal synchronization protocol, the task-purge protocol can be logically reduced to the following sequence:
The picture shows the following sequence: set parameters; get parameters; process request; clean up.

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.

The following shows the programming steps that conform to these rules:
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 different approach is as follows; if task A is to be purged:
  1. A communicates to B that it is no longer available, thus informing B not to use any resources owned by A.
  2. A performs its own clean-up processing (including issuing the RESUME call for the purged SUSPEND, as required by the dispatcher protocols), and abends.
  3. B performs its own clean-up processing.


dfha3c0081.html | Timestamp icon Last updated: Monday, 5 June 2017