Examples of WAIT Statements

In the following example, if the happened state of event EVNT is TRUE (happened), the program continues with the next statement. Otherwise, the program is suspended until EVNT is caused, and the happened state of EVNT is set to TRUE (happened).

WAIT(EVNT)

In the following example, if the happened state of event EVNT1, EVNT2, or EVNT3 is TRUE (happened), the program continues with the next statement. Otherwise, the program is suspended until one of the events EVNT1, EVNT2, or EVNT3 is caused, and the happened state of that event is set to TRUE (happened).

WAIT(EVNT1,EVNT2,EVNT3)

The following example is identical to the previous one except that the first event tested is determined by the value of START_EVENT.

WAIT(EVNT1,EVNT2,EVNT3) [START_EVENT]

In the following example, if the happened state of WAKEUP or GOAWAY is TRUE (happened), the program continues with the next statement. Otherwise, the program is suspended until NAPTIME seconds have elapsed or until event WAKEUP or GOAWAY is caused. If WAKEUP or GOAWAY is caused, its happened state is set to TRUE (happened). The value stored in X is 1, 2, or 3, indicating which of the three items reactivated the program.

X := WAIT((NAPTIME),WAKEUP,GOAWAY)

In the following example, if the happened state of WAKEUP or GOAWAY is TRUE (happened), the program continues with the next statement. Otherwise, the program is suspended until NAPTIME seconds have elapsed or until event WAKEUP or GOAWAY is caused or the process receives a signal. If a signal is received before the WAKEUP or GOAWAY is caused (happened) and before NAPTIME seconds elapses, the value stored in X is 0 (zero), indicating that the wait was interrupted by a signal.

X := WAIT [INTERRUPTIBLE] ((NAPTIME),WAKEUP,GOAWAY)

In the following example, if DIRINPUT is a direct array row, the program is suspended until the direct I/O operation associated with DIRINPUT is completed. If the I/O operation fails, the value TRUE is assigned to RSLT. If the operation is successful, the value FALSE is assigned to RSLT.

RSLT := WAIT(DIRINPUT)

In the following example, the program is suspended until an attached and enabled interrupt is invoked as a result of the associated event being caused:

WAIT

In the following example, if a STOQUE entry is available in the storage queue identified by STOQ1 or if OBJECT/TEST is ready to send data, the program continues with the next statement. Otherwise, the program is suspended until either of these conditions is true. The value stored in WHICH is 1 or 2, indicating which of the two items reactivated the program.

WHICH := WAIT (STOQ_INPUT STOQ1, CRCR_INPUT "OBJECT/TEST.")