Serializing access to resources (ISGENQ macro)

When one or more programs using a serially reusable resource modify the resource, they must not use the resource simultaneously with other programs. Consider a data area in virtual storage that is being used by programs associated with several tasks of a job step. Some of the programs are only reading records in the data area; because they are not updating the records, they can access the data area simultaneously. Other programs using the data area, however, are reading, updating, and replacing records in the data area. Each of these programs must serially acquire, update, and replace records by locking out other programs. In addition, none of the programs that are only reading the records want to use a record that another program is updating until after the record has been replaced.

If your program uses a serially reusable resource, you must prevent incorrect use of the resource. You must ensure that the logic of your program does not require the second use of the resource before completion of the first use. Be especially careful when using a serially reusable resource in an exit routine; because exit routines get control asynchronously with respect to your program logic, the exit routine could obtain a resource already in use by the main program. When more than one task is involved, using the ISGENQ macro correctly can prevent simultaneous use of a serially reusable resource.

z/OS® Automatic Tape Switching (ATS STAR) uses the ISGDGRSRES exit to add additional device information to the DISPLAY GRS command. For information and an example, see Providing ENQ resource information on DISPLAY GRS command in z/OS MVS Programming: Authorized Assembler Services Guide.

The ISGENQ macro assigns control of a resource to the current task. The control program determines the status of the resource and does one of the following:

When the status of the resource changes so that the waiting task can get control, the task is taken out of the wait condition and placed in the ready condition.