Implicitly Initiating a Server Library

Initiations Caused by Linkage Attempts

If a client process attempts to link to a server library, then in some cases the library linkage mechanism attempts to initiate a new instance of the server library. This initiation is referred to as an implicit initiation.

The linkage attempt that causes the implicit initiation could be an explicit linkage, an implicit linkage, or a direct linkage.

Task Attribute Inheritance

The library process inherits task attributes from the client process if the library is initiated implicitly, unless the linkage mode is BYFUNCTION and the SHARING option is SHAREDBYALL. The library process inherits the same task attributes that an ordinary task inherits from its initiator.

Waiting for the Library to Freeze

While the system is performing an implicit initiation, the client process enters a waiting state. The STATUS task attribute is still ACTIVE, but the stack state in the Y (Status Interrogate) system command is WAITING ON AN EVENT. The library linkage mechanism of the operating system automatically initiates the server library program, which executes normally until it freezes and becomes a server library process. At this point, the system completes the linkage between the client library and the server library, and the client process resumes execution.

If you do not wish to expose a client process to the potential delay involved in an implicit initiation, then you should use explicit linkage with the LINKLIBRARY function, and specify the DONTWAIT option. If a frozen instance of the library is not available, the LINKLIBRARY function returns with an error result. The following is an example of such a function:

RSLT:= LINKLIBRARY (LIB1, DONTWAIT);

Libraries with Limited Sharing

Even if an instance of the server library is already frozen, the system might initiate a new instance of the server library for the client library to link to. For example, if the sharing option of the server library is PRIVATE, then the system initiates a new instance of the library for each client library. If the sharing option is SHAREDBYRUNUNIT, then the system initiates a new instance of the server library program for each run unit that uses the server library. (Refer to Controlling Server Library Sharing for more information.)

Limited Sharing Causes Limited Library Duration

If a PRIVATE or SHAREDBYRUNUNIT server library is initiated through the library linkage mechanism and the library requests a permanent freeze, the system actually freezes the library as a temporary library. The system does this because a PRIVATE or SHAREDBYRUNUNIT library instance can only be linked to by a client library once. Thus, no purpose would be served by allowing the library instance to linger after the original client delinks.

Programs That Cannot Become Libraries

If an attempt is made to link a client library to a program that is not capable of becoming a library, then the library linkage mechanism issues the error “LIBRARY WAS NOT INITIATED: <library name>“ and discontinues the client process. This error can happen, for example, if the client process attempts to link to an ALGOL program that does not contain a FREEZE statement.

Waiting for a Delayed Freeze

Because a server library program initially runs as a regular program, the flow of execution can be such that the execution of a FREEZE statement is conditional and can occur anywhere in the program. If the library linkage mechanism initiates such a program, and the client process waits longer than one minute for the library to freeze, the system displays the following message for the user process:

Waiting For Library (Mix <mix number> to Freeze

If you miss seeing the original display of this message, you can use the Y (Status Interrogate) system command. The message appears in the Display line of the Y command output.

Libraries That Never Freeze

If the library process terminates without ever having executed a FREEZE statement, the system returns an error condition. For implicit linkage attempts, this condition causes the client process to be discontinued and displays the following message:

LIBRARY DID NOT FREEZE: <library name>

For explicit linkage attempts, the LINKLIBRARY function returns an error indication, and the client process continues execution.