Description

Use the SETLOCK macro to control access to serially reusable resources. Each kind of serially reusable resource is assigned a separate lock.

SETLOCK can do the following:
  • Obtain a specified lock
  • Release a specified lock
  • Test a specified lock or determine if the lock is held on the caller's processor.

Locks are discussed in the “Serialization” chapter in z/OS MVS Programming: Authorized Assembler Services Guide.

Note: The OBTAIN, RELEASE, and TEST options of the SETLOCK macro have the same environmental specifications, programming requirements, restrictions, register information, and performance implications described below, except where noted in the explanations of each option.

Environment

The requirements for the caller are:

Environmental factor Requirement
Minimum authorization: Supervisor state, PSW key 0
Dispatchable unit mode: Task or SRB
Cross memory mode: Any
AMODE: 24- or 31-bit
ASC mode: Primary or access register (AR)
Interrupt status: Enabled or disabled for I/O and external interrupts. The caller cannot be disabled when unconditionally requesting a suspend lock.
Locks: LOCAL or CML lock must be held to obtain the CMS lock; otherwise, the caller may hold locks, but is not required to hold any. Only locks lower in the hierarchy than the lock currently being requested may be held at the time of invocation.
Control parameters: None.

Programming requirements

  • Before you invoke the SETLOCK macro in access register mode, issue SYSSTATE ASCENV=AR.
  • The caller must include the IHAPSA mapping macro.
  • Before issuing an OBTAIN request for a CML lock, establish the target ASCB as either the primary or secondary address space.

Restrictions

None.

Input register information

Before issuing the SETLOCK macro, the caller must ensure that the following general purpose register (GPR) contains the specified information:
Register
Contents
13
A 5-word save area if REGS=SAVE is specified, or an 18-word save area if REGS=STDSAVE is specified.

Output register information

For an OBTAIN or RELEASE request, when the REGS parameter is not specified, the contents of the general purpose registers (GPRs) after control returns to the caller are as follows:
Register
Contents
0-10
Unchanged
11-12
Used as work registers by the system
13
Return code
14
Used as a work register by the system
15
Unchanged

For an OBTAIN or RELEASE request when the REGS parameter is specified, see the description of the REGS parameter for information on GPR usage.

For a TEST request, the contents of the GPRs after control returns to the caller are as follows:
Register
Contents
0-1
Unchanged.
2-12
If one of these registers is specified on the LOCKHLD parameter, that register is used as a work register by the system; otherwise, registers 2-12 are unchanged.
13-14
Unchanged.
When control returns to the caller, the access registers (ARs) contain:
Register
Contents
0-1
Used as work registers by the system
2-13
Unchanged
14-15
Used as work registers by the system

Some callers depend on register contents remaining the same before and after issuing a service. If the system changes the contents of registers on which the caller depends, the caller must save them before issuing the service, and restore them after the system returns control.

Performance implications

None.