LOCK Interlock Statement

<lock interlock statement>

── LOCK ─┬───────────────────────────┬─ ( ──<interlock designator>─────►
         └─ <lock interlock option> ─┘
►─┬──────────────────────────┬─ ) ─────────────────────────────────────┤
  └─ , ─┬─<timeout>──────────┤
        └─<event designator>─┘

<lock interlock option>

── [ ─┬─ DSABLE ────────┬─ ] ──────────────┤
      ├─ INTERRUPTIBLE ─┤
      └─ STRICT ────────┘

<timeout>

──<arithmetic expression>──────────────────────────────────────────────┤

The LOCK interlock statement attempts to acquire the interlock. The LOCK interlock can be used as a function. If LOCK interlock is used as a statement, the process is discontinued when the result is a value other than 1 (successfully acquired).

If an event designator is present and the interlock cannot be acquired immediately, the caller waits until either the interlock can be acquired or the event state is HAPPENED. The event cannot have an interrupt attached or be inscribed for use with a POBOX. If the event is used in either of these two ways, a result of 10 is returned.

When an isolated procedure is waiting to acquire an interlock while being run by another process, the DSABLE option specifies that the wait can be terminated if the calling process is discontinued. If the wait was terminated before the interlock could be acquired, the function value returned is zero.

If the interlock cannot be acquired immediately and the INTERRUPTIBLE option is used, the caller waits until either the interlock can be acquired, the timeout or event happens, or a signal is sent to the program. If the process is awakened by receipt of a signal, the function value is zero (0).

The LOCK interlock function is of the type INTEGER, and the following values can be returned:

Note: If the caller already owns the interlock and the STRICT option is used, a result of 8 is returned.

Value

Meaning

0

A signal was received before the interlock could be acquired.

1

The interlock was successfully acquired.

2

The timeout elapsed or the event happened (event state HAPPENED), before the interlock could be acquired.

8

The caller already owns the interlock.

10

The event used has a conflicting usage, such as an attached INTERRUPT.

The following conditions cause various values to be returned:

  • If the interlock has a state of FREE, it becomes LOCKED_UNCONTENDED, and a result of 1 is returned.

  • If the interlock is LOCKED_UNCONTENDED, it becomes LOCKED_CONTENDED, and the caller is placed in the contender list. When the owner unlocks the interlock, and the caller is at the head of the contender list, a result of 1 is returned. If the timeout expires before the caller can acquire the interlock, a result of 2 is returned. If the caller that timed out is the only contender, the interlock becomes LOCKED_UNCONTENDED.

  • If the interlock is LOCKED_CONTENDED, its state does not change, and the caller is added to the contender list.