CHANGE Procedures for Server or Client Libraries
Server libraries and client libraries can each specify CHANGE procedures that monitor changes in the library linkage state. You can specify a CHANGE procedure for only the client library, for only the server library, for both the client library and the server library, or for neither.
Declaring a CHANGE Procedure
To use a CHANGE procedure in a server library, you must declare a procedure in the library that accepts a standard set of parameters from the operating system. You must also include an EXPORTLIBRARY statement that includes an assignment to the CHANGE library attribute. The CHANGE attribute specifies the name of the procedure to be used as the CHANGE procedure. For example, the following ALGOL statement in a server library specifies that the library is using a CHANGE procedure called CHG1:
EXPORTLIBRARY (CHANGE = CHG1);
To use a CHANGE procedure in a client program, you must declare a procedure with the required parameters in the client program. You must also assign the procedure name to the CHANGE attribute in the client library declaration.
When the CHANGE Procedure Is Invoked
The system invokes the CHANGE procedure for the server library whenever any client process completes linking to the server library or begins delinking from the server library. The system invokes the CHANGE procedure for the client library whenever that client process completes linking to or begins delinking from the server library.
Parameters to the CHANGE Procedure
The system passes parameters to each invocation of the CHANGE procedure including the new linkage state, the reason for the change in linkage state, and an indication of whether the client process is terminating abnormally. The CHANGE procedure can read the parameter values but does not return any value itself.
Modifying Global Objects
The CHANGE procedure can modify globally-declared objects such as events in the program that declared the CHANGE procedure (either the server library or the client process). These modifications can be used to inform the server library process or client process of the change in linkage state.
Control Libraries and CHANGE Procedures
If a server library has performed a control freeze, the control procedure can include statements to monitor and respond to any changes made to global objects by the CHANGE procedure. If the server library has a permanent or temporary freeze, the server library cannot directly detect any changes to global objects made by the CHANGE procedure. However, before the server library performs a permanent or temporary freeze, the server library could initiate an asynchronous task to monitor changes to global objects in the library.
Keeping Track of Client Processes
The CHANGE procedure does not provide any indication to a server library process of which client process has just linked or delinked. However, the server library process could keep a running count of the number of linkages and delinkages, so know how many client processes are linked at a given time.
| Note: | A server library cannot determine its current number of clients by reading the LIBRARYUSERS task attribute inside the CHANGE procedure, because the MYSELF task variable in a CHANGE procedure does not refer to the server library process. |
For a description of the CHANGE procedure, refer to the discussion of the CHANGE library attribute under Using Library Attributes later in this section.

