The following paragraphs illustrate the nature of circular linkage and circular provision through several examples.
Example 1: Circular Provision of a Single Procedure
Circular Provision of a Single Procedure shows one example of a circular linkage:
In Circular Provision of a Single Procedure,
-
The arrows point from import procedures to the corresponding export procedures.
-
Client program CL1 imports procedure X from server library SL1.
-
SL1 provides procedure X indirectly by importing procedure X with an ACTUALNAME of Y from server library SL2.
-
SL2 provides procedure Y indirectly by importing procedure Y from server library SL3.
-
SL3 provides procedure Y indirectly by importing procedure Y from server library SL1.
In this example, the library linkage is circular because server library SL1 is both the first and the last library in the linkage series.
The provision of procedure X is also circular, because import object X in SL1 is ultimately provided by export object Y in the same library, SL1.
Example 2: Circular Linkage without Circular Provision
The definition of circular library linkages is actually broader than Example 1 would suggest. The operating system might consider a series of linkages to be circular even if no single object is exported through the entire chain. Circular Linkage without Circular Provision shows an example of this type of circular linkage:
In Circular Linkage without Circular Provision,
-
The arrows point from import procedures to the corresponding export procedures.
-
Client library CL1 imports procedure A from server library SL1.
-
Server library SL1 imports procedure X from server library SL2.
-
Client library CL2 imports procedure B from server library SL2.
-
Server library SL2 imports procedure Y from SL1.
In this example, library programs SL1 and SL2 are linked in a way that the operating system considers circular. The linkage is considered circular because each library imports an object from the other library (even though it is not the same object).
On the other hand, this example is not an example of circular provision. Procedures A, B, X, and Y are each provided directly.
Example 3: Circular Linkage Including a Connection Library
A connection library can be included in a circular linkage. Consider the following example:
In Circular Linkage Including a Connection Library,
-
The arrows point from import procedures to the corresponding export procedures.
-
Program PROG1 declares a client library CLIENT1, which imports procedure X from connection library CONLIB1 in program PROG2.
-
Program PROG2 contains two connection libraries: CONLIB1 and CONLIB2. Connection library CONLIB1 exports procedure X to CLIENT1 in PROG1. Connection library CONLIB2 imports procedure Y from server library program PROG3.
-
PROG3 includes a client library CLIENT3, which imports procedure Z from connection library CONLIB3 in program PROG1.
Note that, in this example, the linkage among library declarations is not continuous. That is, CLIENT1 links to CONLIB1, and CONLIB2 links to PROG3, but CONLIB1 never links to CONLIB2. Nevertheless, this example is considered a circular linkage, because the linkage proceeds from a library in PROG1 to a library in PROG2, from a library in PROG2 to a library in PROG3, and from a library in PROG3 back to a library in PROG1.
On the other hand, this example is not an example of circular provision. Procedures X, Y, and Z are each provided directly.
Example 4: Circular Linkage with an Extra Connection Library Linkage
Although circular linkages can include connection libraries, a circular linkage cannot depend on a link between two connection libraries. Thus, in Example 3, the connection library CONLIB1 is linked to client library CLIENT1, and connection library CONLIB2 is linked to server library PROG3. The circularity does not depend on any linkages between two connection libraries.
Now, suppose that a linkage is added to Example 3, so that CONLIB1 imports a procedure from CONLIB2. The result is shown in Circular Linkage with an Extra Connection Library Linkage.
In this example, the arrows point from import procedures to the corresponding export procedures.
In this case, the operating system still considers linkage as circular, but it does not include the link between CONLIB1 and CONLIB2. In general, to determine whether a given series of linkages is circular, you should ignore those linkages that exist between two connection libraries, and then see if the linkage series is still circular.
Example 5: Noncircular Linkage Involving Connection Libraries
The following is an example of a linkage that appears to be circular, but is not considered circular by the operating system:
In this example,
-
The arrows point from import procedures to the corresponding export procedures.
-
Program PROG1 declares a connection library CONLIB1, which imports procedure X from connection library CONLIB2 in program PROG2.
-
Program PROG2 contains both connection library CONLIB2 and client library CLIENT1. Client library CLIENT1 imports procedure Y from server library program PROG3.
-
PROG3 includes a client library CLIENT2, which imports procedure Z from connection library CONLIB1 in program PROG1.
The preceding example appears to include a circular linkage, because the linkage proceeds from a library in PROG1 to a library in PROG2, from a library in PROG2 to a library in PROG3, and from a library in PROG3 back to a library in PROG1. However, if you ignore the linkage between the two connection libraries (CONLIB1 and CONLIB2), you can see that there is no longer any link between programs PROG1 and PROG2. Because this linkage series depends on a linkage between two connection libraries, this linkage series is not considered circular.
Example 6: Circular Linkage with a Connection Library as Client
A connection library can import an object from a server library that, in turn, is part of a circular linkage. For example:
In this example,
-
The arrows point from import procedures to the corresponding export procedures.
-
Program PROG1 contains connection library CONLIB1, which imports procedure W from server library PROG2.
-
Server library PROG2 imports procedure X from server library PROG3.
-
Server library PROG3 imports procedure Y from server library PROG4.
-
Server library PROG4 imports procedure Z from server library PROG2.
In this example, the server libraries PROG2, PROG3, and PROG4 are linked circularly. However, procedure W is not actually provided circularly. Procedure W, which is imported by CONLIB1, is provided directly by PROG2. If PROG2 provided procedure W indirectly by importing W from another library, then the system would not allow CONLIB1 to invoke W. In general, the system does not allow connection libraries to use objects that are provided indirectly, as discussed under Indirect Provision earlier in this section.







