Suspend exit routine

The suspend exit routine is required. It is responsible for saving the suspend token. Additionally, it makes the decision whether to suspend an SRB or allow it to continue running. The system invokes the exit routine when an SRB routine issues the SUSPEND macro and identifies the exit on the EXIT parameter. The exit routine must be addressable in the primary address space of the program that issued the SUSPEND macro. Input to the exit routine is the address of the suspend token. The exit routine must store the suspend token and not alter it.

The SRB routine can pass parameters to the exit routine; the EXITPARM parameter on SUSPEND points to the address of the parameter list. The exit routine and the SRB routine determine the format of the list.

Environment on Entry: On entry to the exit routine, the following environment exists. This same environment must exist when the exit routine returns control to its caller.

Environmental factor Requirement
Authorization: Supervisor state and PSW key 0
Dispatchable unit mode: SRB (The same SRB that represents the issuer of SUSPEND.)
Cross memory mode: NewHASN = oldHASN, newPASN = oldPASN, newSASN = oldPASN
AMODE: 31-bit
ASC mode: Same as the program that issued SUSPEND
Interrupt status: Enabled for I/O and external interrupts
Locks: If the calling program holds the local or CML lock, the exit routine holds the lock when invoked.
Registers on Entry: On entry to the exit routine, the general purpose registers contain:
Register
Contents
0
Address of the exit routine parameters specified by the EXITPARM parameter of SUSPEND
1
Address of the suspend token
2 - 13
Used as work registers by the system
14
Return address
15
Entry point address
The access registers contain:
Register
Contents
0
ALET that qualifies the address of the exit routine parameters
1
ALET of the suspend token
2 - 15
Used as work registers by the system

To suspend the SRB, the exit routine must place a return code of 0 into register 15. If the caller of the SUSPEND macro holds a local or CML lock, SUSPEND releases the lock when the exit routine passes control back to it and passes a return code of 0. To subsequently resume the SRB, a program will need to use the suspend token. Therefore, the exit routine must store the suspend token in a location that will be addressable by any program that resumes the SRB. For example, the exit routine might store the token in common storage, then set a flag to indicate that the token is stored and the exit has finished processing. On exit, the access registers and general purpose registers 0 - 13 can contain any values placed there by the exit routine. To return to the caller, the exit routine must issue a BR 14 instruction.

To allow the SRB to continue running, the exit must place a return code of 4 into register 15. Optionally, the exit routine can also place a fullword resume code into register 0. The system returns the resume code to the resumed SRB routine. On exit, the access registers and general purpose registers 1 - 13 can contain any values the exit routine places there. To return to the caller, the exit routine must issue a BR 14 instruction.