By attaching a subtask and passing a copy of the DU-AL, a program can share its existing data spaces with a program that runs under the subtask. In this way, the two programs can share the SCOPE=SINGLE data spaces that were represented on the DU-AL at the time of the attach. The ALCOPY=YES parameter on the ATTACH or ATTACHX macro allows a problem-state program to pass a copy of its DU-AL to the subtask the problem-state program is attaching. Passing only a part of the DU-AL is not possible.
A program can use the ETXR option on ATTACH or ATTACHX to specify the address of an end-of-task routine to be given control after the new task is normally or abnormally terminated. The exit routine receives control when the originating task becomes active after the subtask is terminated. The routine runs asynchronously under the originating task. Upon entry, the routine has an empty dispatchable unit access list (DU-AL). To establish addressability to a data space created by the originating task and shared with the terminating subtask, the routine can use the ALESERV macro with the ADD parameter, and specify the STOKEN of the data space.
In the following example, shown in Figure 1, assume that program PGM1 (running under TCBA) has created a SCOPE=SINGLE data space DS1 and established addressability to it. PGM1's DU-AL has several entries on it, including one for DS1. PGM1 uses the ATTACHX macro with the ALCOPY=YES parameter to attach subtask TCBB and pass a copy of its DU-AL to TCBB. It can also pass ALETs in a parameter list to PGM2. Upon return from ATTACHX, PGM1 and PGM2 have access to the same data spaces.
DSPSERV CREATE,NAME=DSNAME,BLOCKS=DSSIZE,STOKEN=DSSTOK, *
ORIGIN=DSORG
ALESERV ADD,STOKEN=DSSTOK,ALET=DSALET
ATTACHX EP=PGM2,ALCOPY=YES
.
.
DSNAME DC CL8'TEMP ' DATA SPACE NAME
DSSTOK DS CL8 DATA SPACE STOKEN
DSALET DS F DATA SPACE ALET
DSORG DS F ORIGIN RETURNED
DSSIZE DC F'2560' DATA SPACE 10 MEGABYTES IN SIZE
The DU-ALs do not necessarily stay identical. After the attach, PGM1 and PGM2 can add and delete entries on their own DU-ALs; these changes are not made to the other DU-AL.
If TCBA terminates, the system deletes the data space that belonged to TCBA and terminates PGM2.