Types of locks

The type of lock determines what happens when a function on one processor in an MP system makes an unconditional request for a lock that is held by another unit of work on another processor. There are two major types of locks: spin and suspend. The CPU lock is in a category by itself but could be considered a pseudo spin lock. Descriptions of these types of locks follow:
  • Spin lock -- prevents the requesting function on one processor from doing any work until the lock is freed on another processor. A spin lock causes disablement.
  • CPU lock -- provides MVS-recognized (valid) disablement for I/O and external interrupts. MVS-recognized disablement refers to disablement that is obtained through a SETLOCK OBTAIN TYPE=CPU request. While a requestor holds the CPU lock, the requestor is physically disabled for I/O and external interrupts.

    Certain macros require the caller to be disabled for I/O and external interrupts. Unless otherwise specified, this means that the caller must have obtained MVS-recognized disablement. MVS™ does not guarantee preservation of the interrupt status of programs that explicitly disable for I/O and external interrupts through the STNSM instruction.

    Multiple requests can be made by a unit of work for the CPU lock. The CPU lockword contains the cumulative count of requestors who hold the CPU lock. Obtaining the CPU lock increases the ownership count of the CPU lock by 1; releasing the CPU lock decreases the ownership count by 1.

  • Suspend locks -- prevent the requesting program from doing work until the lock is available, but allow the processor to continue doing other work. The requestor is suspended and other work may be dispatched on that processor. Upon release of the lock, the suspended requestor is given control with the lock or is redispatched to retry the lock obtain.
  • If the caller issues a SETLOCK macro to obtain a spin lock, the caller must reference only page fixed, fixed, or DREF storage.