Previous Topic: REXX Coding ConsiderationsNext Topic: The TYPE Host Command


ENQ/DEQ Notes

The ENQ/DEQ mechanism allows multiple OPS/REXX programs to share a virtual terminal. Since nothing prevents a program from getting exclusive control of a virtual terminal (ENQ) and never releasing control of it, the EPI will automatically issue a DEQ for any virtual terminals ENQd by a program under the following circumstances:

In addition, the possibility exists that two REXX programs get into a deadlock situation when ENQing on multiple virtual terminals. Consider the situation of two REXX programs (PGM1 and PGM2) trying to use two virtual terminals (TERMA and TERMB) as follows:

  1. PGM1 issues ENQ TERMA and gets exclusive control of TERMA.
  2. PGM2 issues ENQ TERMB and gets exclusive control of TERMB.
  3. PGM1 issues ENQ TERMB and waits for TERMB.
  4. PGM2 issues ENQ TERMA and waits for TERMA.

Neither program will be able to continue and both virtual terminals are inaccessible by all other REXX programs. To prevent this situation, the following additional protocol is enforced by the EPI: All ENQs must be performed in alphabetical order by virtual terminal name. Therefore, in the above example, the fourth step (ENQ TERMA by PGM2) would have been rejected by the EPI, as PGM2 has already issued an ENQ for TERMB.