ALGOL Incorrect Circular Libraries

The following are examples of libraries and client programs that use circular linkage incorrectly.

Example 1: Indirect Self Referencing

The following is the client program OBJECT/INDIRECT/CALL. This program invokes procedure X in the library OBJECT/INDIRECT/LIB1.

BEGIN
    LIBRARY L(TITLE=“OBJECT/INDIRECT/LIB1”);
    PROCEDURE X;
      LIBRARY L;
    X;
  END.

The following is the library OBJECT/INDIRECT/LIB1. This library provides procedure X indirectly by importing it from another library, OBJECT/INDIRECT/LIB2.

$SHARING = SHAREDBYALL
  BEGIN
    LIBRARY L(TITLE=“OBJECT/INDIRECT/LIB2”);
    PROCEDURE X;
      LIBRARY L;
    EXPORT X;
    FREEZE(PERMANENT);
  END.

The following is the library OBJECT/INDIRECT/LIB2. This library also provides procedure X indirectly, in this case by importing procedure X from OBJECT/INDIRECT/LIB1.

$SHARING = SHAREDBYALL
  BEGIN
    LIBRARY L(TITLE=“OBJECT/INDIRECT/LIB1”);
    PROCEDURE X;
      LIBRARY L;
    EXPORT X;
    FREEZE(PERMANENT);
  END.

This chain of linkages is completely circular. That is, the chain leads back not just to the original library, but also to the original procedure. When the client program invokes procedure X, the system discontinues the program and displays the message “CURRENT CIRCULAR LIBRARY REFERENCE STRUCTURE IS NOT ALLOWED.”

Example 2: Direct Self Referencing

The following ALGOL library, called OBJECT/ALGOL/SELF/LIB, attempts to provide a procedure by importing it from the same procedure in the same library. When a client process attempts to invoke procedure X in this library, the client process hangs. The Y (Status Interrogate) system command shows a STACK STATE of WAITING ON AN EVENT, but the process does not appear in the W (Waiting Mix Entries) system command display. This situation continues until an operator enters a DS (Discontinue) system command or until the system is halt/loaded.

$SHARING = SHAREDBYALL
  BEGIN
    LIBRARY L(TITLE=“OBJECT/ALGOL/SELF/LIB”);
    PROCEDURE X;
       LIBRARY L;
    EXPORT X;
    FREEZE(TEMPORARY);
  END.

Example 3: Libraries That Wait on Each Other

The following client program invokes a procedure in the library OBJECT/LIB/WAIT1.

BEGIN
    LIBRARY L(TITLE=“OBJECT/LIB/WAIT1.”);
    PROCEDURE X;
       LIBRARY L;
    X;
  END.

The following is the library OBJECT/LIB/WAIT1. Before freezing, this library invokes a procedure in the library OBJECT/LIB/WAIT2.

$SHARING = SHAREDBYALL
  BEGIN
    LIBRARY L(TITLE=“OBJECT/LIB/WAIT2.”);
    PROCEDURE X;
       LIBRARY L;
    PROCEDURE Y;
       DISPLAY (“Y”);
    EXPORT X, Y;
    X;
    FREEZE(TEMPORARY);
  END.

The following is the library OBJECT/LIB/WAIT2. Before freezing, this library invokes a procedure in the library OBJECT/LIB/WAIT1.

$SHARING = SHAREDBYALL
  BEGIN
    LIBRARY L(TITLE=“OBJECT/LIB/WAIT1.”);
    PROCEDURE Y;
       LIBRARY L;
    PROCEDURE X;
       DISPLAY (“X”);
    EXPORT X, Y;
    Y;
    FREEZE(TEMPORARY);
  END.

Because OBJECT/LIB/WAIT1 was initiated through the library linkage mechanism, is SHAREDBYALL, and has not yet frozen, OBJECT/LIB/WAIT2 waits for OBJECT/LIB/WAIT1 to freeze. Both libraries are then waiting for each other to freeze. The client process hangs indefinitely. The Y (Status Interrogate) system command shows the client process to have a STACK STATE of WAITING ON AN EVENT, but the client process does not appear in the W (Waiting Mix Entries) system command display. This situation continues until an operator enters a DS (Discontinue) system command or until the system is halt/loaded.