Sharing task-lifetime storage

The use of any task-lifetime storage belonging to one task can be shared with another task, provided the owning task can pass the address to the other task in the same CICS address space.

This technique creates an affinity among the communicating tasks, and requires that any task retrieving and using the passed address must execute in the same target region as the task owning the task-lifetime storage.

For example, it is possible to use a temporary storage queue to pass the address of a PL/I automatic variable, or the address of a COBOL working-storage structure (see Figure 1 for an example).
Figure 1. Illustration of inter-transaction affinity created by use of task-lifetime storage. TRN2 must execute in the same target region as TRN1. Also, TRN1 must not terminate until TRN2 has finished using its task-lifetime storage.
TRN1 executes in AOR1 and stores the address of task-lifetime storage in a TS queue for TRN2 and suspends. TRN2 executes in AOR1, accesses the storage and resumes TRN1.

For two tasks to share task-lifetime storage belonging to one of them requires that the tasks are synchronized in some way. See Table 1 for commands that provide ways of suspending and resuming a task that passes the address of its local storage.

Table 1. Methods for suspending and resuming (synchronizing) tasks
Suspending operation Resuming operation
WAIT EVENT, WAIT EXTERNAL, WAITCICS POST
RETRIEVE WAIT START
DELAY CANCEL
POST CANCEL
START CANCEL
ENQ DEQ
Some of these techniques themselves require that the transactions using them must execute in the same target region, and these are discussed later. However, even in those cases where tasks running in different target regions can be synchronized, it is not safe to pass the address of task-lifetime storage from one to the other. Even without dynamic routing, designs that are based on the synchronization techniques shown in Table 1 are fundamentally unsafe because it is possible that the storage-owning task could be purged.
Note:
  1. Using synchronization techniques, such as RETRIEVE WAIT/START, to allow sharing of task-lifetime storage is not recommended.
  2. No inter-transaction affinity is caused in those cases where the task sharing another task's task-lifetime storage is started by an START command, except when the START command is function-shipped or routed to a remote system.