Suspending an SRB until an event completes (SUSPEND macro)

The SUSPEND macro enables an SRB routine to suspend execution until an event occurs that requires the routine to resume execution.

To issue SUSPEND from an SRB routine, code both the SPTOKEN parameter and the EXIT parameter. SPTOKEN defines the address of an 8-byte location where the system returns a token called the suspend token. This token uniquely identifies the suspended SRB and is subsequently used by the suspend exit routine and the RESUME macro. The EXIT parameter defines the address of the user-provided suspend exit routine. This exit routine stores the suspend token and decides whether to suspend the SRB or allow it to continue running. The SRB routine can pass a parameter list to the exit routine; the EXITPARM parameter on the SUSPEND macro points to this parameter list. For information on how to write this exit, see Suspend exit routine.

Optionally, you can also code the RSCODE parameter. RSCODE provides the address of a fullword, called the resume code. The resume code provides a means for the exit routine or the program that subsequently resumes the SRB to communicate with your program. The exit routine and the program that issues the RESUME macro have the option of storing a fullword value in the resume code. The meaning of the value is a decision that must be made among the macro callers and the exit designer.

After the SUSPEND macro is issued, one of the following actions occur depending on the suspend exit's decision:
  • The SRB routine continues to run, in which case, control immediately returns to the instruction following the SUSPEND macro.
  • The SRB is suspended. A suspended SRB remains suspended until a program subsequently issues the RESUME macro to resume SRB execution or to purge the SRB from the system. A resumed SRB resumes execution at the instruction following the SUSPEND macro. A purged SRB never regains control.