Releasing the resource

Use the RELEASE request to release a serially reusable resource that you obtained by using ISGENQ macro. If a task tries to release a resource which it does not control, the control program either returns a non-zero return code or abends the task. The control program might place many tasks in a wait condition while it assigns control of the resource to one task. Having many tasks in the wait state might reduce the amount of work being done by the system, therefore, you should release the resource, so that another task can use it.

If a task terminates without releasing a resource, the control program releases the resource automatically. By default, outstanding ENQs have affinity to the task that issued the ENQ. The system releases any outstanding ENQs during termination as follows:
  • Task termination: The user should provide a recovery routine to back out or complete any processing that requires the serialization and then release any ENQs before the program gives up control. The system automatically releases all of a task's outstanding ENQs after all recovery routines and task related dynamic resources managers have executed.
  • Memory termination: The system releases all ENQs during memory termination processing in cases where task related recovery and termination resource managers may not have run. The ENQs are released after all memory termination dynamic resource managers have executed.

    Note that authorized routines that may get control under a resource manager must prevent themselves from getting deadlocked. They may need to conditionally request an ENQ or query if it is already outstanding by the address space that is in memory termination. They cannot obtain nor release an ENQ that was obtained by the terminating space. However, they are guaranteed that no processing can take place in the space that is terminating. As such, they can use the outstanding serialization to perform any required back out or completion processing.