The resource manager termination routine (RMTR)

If the system has purged the SRB from the dispatching queue before the SRB routine can run, PURGEDQ calls the RMTR associated with the SRB. The primary purpose of the RMTR is to clean up the SRB. The routine can either free the SRB storage by invoking the FREEMAIN or the STORAGE RELEASE macro or mark the SRB so that it can be reused. The choice depends on how your application manages its SRBs.

The RMTR must be commonly addressable from all address spaces and must remain in supervisor state. One RMTR can provide recovery for more than one SRB. However, then you must be more careful when you tell the PURGEDQ macro which SRB (or SRBs) to purge.

At entry, the RMTR is enabled, in task mode, in supervisor state, with PSW key 0. If requested either by bit 31 of RMTRADDR being on for IEAMSCHD or by SRBRMTLL being on, the RMTR will receive control with the local lock held. Otherwise, no locks will be held. Entry register contents are as follows:
Register
Contents
0
Contents of register 0 of the caller of PURGEDQ at the time the PURGEDQ macro was issued. This register allows the caller of PURGEDQ to pass information to the RMTR. This information can be a pointer or data. Register 0 contains zero if the SRB was purged by the system during address space or task termination.
1
For IEAMSCHED, 0. For SCHEDULE, the address of the dequeued SRB.
2
For IEAMSCHD, this is the contents specified on the PARM keyword for the SRB. For SCHEDULE, this is the contents specified on SRBPARM for the SRB.
14
Return address to PURGEDQ.
15
Entry point of RMTR.

The RMTR must return control using a BR 14, enabled, in supervisor state with PSW key 0. If the local lock was held on entry, the RMTR is allowed to release the local lock before returning, but is not required to do so. No other locks may be held upon return. If the local lock was not held on entry, the RMTR must return with no locks held. The RMTR is allowed to acquire locks, release locks, issue SVCs and use input registers without first saving the contents during its processing.