Delinking from Server Libraries

Delinking Libraries Early

The system automatically delinks a client library from a server library when the client process exits the block in which the client library is declared. However, at times it can be useful to delink a client library from a server library at an earlier point. For example, delinking a client process from a server library enables the client process to modify one or more of the client library attributes. Delinking a client process also allows a temporary library process to unfreeze and resume execution. With the exception of the AUTOLINK attribute, none of the attributes of a client library can be modified while the client library is linked to the server library.

Delinking a library is a very costly operation. For more information, refer to Delinkage Overuse.

Two features you can use to explicitly delink a client library from a server library are the DELINKLIBRARY function and the CANCEL statement.

Delinking without Affecting Other Users

The DELINKLIBRARY function delinks the client library from the server library without affecting any of the other processes using the server library. The server library remains frozen, unless it is a temporary library and the delinked process was the only process using the library. However a SHAREDBYRUNUNIT library will remain frozen until its client process terminates. The DELINKLIBRARY function is available in ALGOL, NEWP, and Pascal.

Canceling and Unfreezing a Library

The CANCEL statement also delinks the client library from the server library, but has the following additional effects:

  • Delinks any other clients that are currently linked to the library, and discontinues any of those clients that are doing any of the following:

    • Executing a procedure imported from that library.

    • Waiting to procure an event imported from that library.

    • Using certain UNSAFE features of DMALGOL or NEWP to access objects in the library.

  • Causes the server library process to unfreeze and resume execution as a regular process. This is true regardless of whether the server library has a permanent or temporary freeze.

The CANCEL statement is available in ALGOL, COBOL74, COBOL85, and Pascal.

Canceling SHAREDBYALL Libraries Not Allowed

Only server libraries with a sharing option of PRIVATE or SHAREDBYRUNUNIT can be canceled. An attempt to cancel a client library that is linked to a SHAREDBYALL server library results in the warning message “CANCEL WARNING, SHARED LIBRARY WAS DELINKED.” In this case, the client library is delinked as if it had performed a DELINKLIBRARY function, and the server library process remains frozen unless it is a temporary library with no other clients.

Canceling SHAREDBYRUNUNIT Libraries

If a client process cancels a client library linked to a SHAREDBYRUNUNIT server library, then any other client processes in the same run unit that are currently linked to the server library lose their linkage. The next time one of these processes uses an object in the server library, the system initiates a new instance of the server library and links the client library to the new library instance.

Effect on Clients Sharing the Same Declaration

Note that internal tasks of a client process can link to a server library by way of a single client library declaration, declared globally in the client process. If such an internal task is using a library object when the parent client process executes a DELINKLIBRARY function or a CANCEL statement, the internal task is discontinued.