Purging groups of latch sets

To better understand how latch sets names and requestor IDs might be grouped, look at the following example. Suppose that you have created three latch sets in an address space with the following names:
LATCHSET1 DC CL48'EXAMPLE.ONE_LATCH_SET_1'
LATCHSET2 DC CL48'EXAMPLE.ONE_LATCH_SET_2'
LATCHSET3 DC CL48'EXAMPLE.ONE_LATCH_SET_3'
There are multiple tasks doing spaced-switched program calls (PCs) into this address space which will be obtaining and releasing latches from these latch sets. For a requestor_ID, the following is used:
MVC  REQ_IDH,PSAAOLD-PSA     /* use home ASCB address and   */
MVC  REQ_IDL,PSATOLD-PSA     /* TCB address as requestor ID */

The first word of the requestor_ID contains the ASCB address of the home address space and the second word is the address of the TCB. For each address space, that has tasks using the latch sets, an end-of-memory resource manager is set up. If you are also using SRBs that would obtain and release latches you could use a similar scheme for the requestor IDs. For instance, the first word could be the ASCB and the second word could be the address of some control block in common (so that the address would be unique and different from the TCB address used by the non-SRB requestors). This is especially useful when the unique portion of the requestor_ID may not be readily determinable by the latch purge requestor.

When one of these address spaces terminates it may still hold one or more of the latches. When the resource manager gets control (it will be running in the master address space), it PCs into our address space to issue the ISGLPBA service. The following example sets up the parameters for this service:
     USING RMPL,R4
     MVC   REQ_IDH,RMPLASCB      /* use the terminating ASCB addr */
     MVC   REQ_IDL,ZEROS         /* rest of req_id should be zero */
The requestor_ID mask would then be:
    REQID_MK DC    4X'FF'         /* match terminating ASCB */
                   XL4'0'         /* mask off TCB address - */
    *                             /* purge latches for      */
    *                             /* for all tasks          */
The latch set name would be the common portion followed by zeros for the unique part:
    LSNME    DC    CL22'EXAMPLE.ONE_LATCH_SET_'  /* common part */
             DC    XL26'0'                       /* unique part */
And the mask would be:
    LSNME_MK DC    22X'FF'                 /* common part */
             DC    XL26'0'                 /* unique part  */
And the call to the service will be:
    CALL ISGLPBA,(LS_TOKEN,REQ_ID,REQID_MK,           X
                 LSNME,LSNME_MK,RETCD),MF=(E,PBYA_DPL)
Note that LS_TOKEN should be set to zero for the latch_set_name and latch_set_name_mask to be used.
    LS_TOKEN DC    XL8'0'                 /* use latch set name and */
    *                                     /* latch set name mask    */
For each latch set in the primary address space, the latch_set_name will be logically ANDed with the latch_set_name_mask:
  latch_set_name     'EXAMPLE.ONE_LATCH_SET_1_..................'

                      CECDDDC7DDC6DCECC6ECE6F4444444444444444444444444
                      57147355655D31338D253D10000000000000000000000000
AND
 latch_set_name_mask  FFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000
                      FFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000
                      _________________________________________________

 result:             'EXAMPLE.ONE_LATCH_SET_..........................'
                      CECDDDC7DDC6DCECC6ECE600000000000000000000000000
                      57147355655D31338D253D00000000000000000000000000

When the result is compared to the latch_set_name operand, LSNME there is a match and the service will try to purge latches in this latch set.

Similarly, for the requestor ID, suppose a requestor in the terminating address space has obtained a latch with the following requestor ID:
       ASCB   TCB

       00FA7880008FD8E0
The service looks at all the requests in this latch set by ANDing the requestor ID with the requestor ID mask and comparing it to the requestor ID operand:
      requestor_ID:          00FA7880008FD8E0
      requestor_ID_mask:     FFFFFFFF00000000
                             ________________
      result:                00FA788000000000

When the result is compared, to the requestor ID operand, there is a match and the latch request will be purged.