Example 2

This example shows a scenario of scheduling an SRB using SCHEDULE and purging the SRB using PURGEDQ. Figure 1 shows SRB storage and five pieces of code:
  • The scheduling program, PGM1, runs in AS1 and needs the service of a routine in another address space.
  • The SRB routine, SRBRTN, runs in address space AS2.
  • A recovery routine, RMTR1, in AS1 performs cleanup operations in case AS2 terminates before SRBRTN can run.
  • A recovery routine, FRR1, in AS1 receives control if PGM1 abnormally ends.
  • A recovery routine, FRR2, in AS2 receives control if SRBRTN abnormally ends.
Figure 1. Example of Scheduling an SRB
ieaa8461

Note that SRBRTN is not required to be in the common area; it could be in the private area of AS2.

Actions of PGM1:
  • STORAGE OBTAIN obtains storage for the SRB from subpool 245.
  • PGM1 initializes the SRB. Contents of some fields are:
    • SRBASCB - the ASCB of AS2
    • SRBPASID - the ASID of AS1
    • SRBPTCB - the address of PGM1's TCB
    • SRBEP - the address of SRBRTN
    • SRBRMTR - the address of RMTR1
    • SRBFRRA - the address of FRR2
  • SETFRR sets up recovery through FRR1 for PGM1.
  • SCHEDULE schedules an SRB. FRR=YES indicates that the scheduling program has set up recovery (through FRR2) for SRBRTN, as defined by SRBFRRA. When the SRB routine gets control, it should fill in the FRR parameter area with the information required by its FRR.
    If the FRR is entered before the SRB routine runs (which would result if, for example, the SRB has affinity but no processors online fit the affinity), then the system fills in the FRR parameter area as follows:
    • Word 1 - Contents of SRBPARM
    • Word 2 - Address of SRB
  • PURGEDQ purges the SRBs that were scheduled to be dispatched and that were associated with the TCB.
Actions of SRBRTN:
  • Initialize the FRR parameter area
  • STORAGE RELEASE frees the SRB storage.
Actions of RMTR1:
  • STORAGE RELEASE frees the SRB storage.
Actions of FRR1 that covers PGM1:
  • STORAGE RELEASE frees the SRB storage (if it has not already been scheduled).
Actions of FRR2 that covers SRBRTN:
  • STORAGE RELEASE frees the SRB storage.
  • If FRR2 percolates, the system abnormally ends PGM1 (because SRBPTCB contains the address of PGM1's TCB).