FREEZE Statement
When a server library program is first initiated, it does not immediately become a library process. In most languages, a server library program is executed as an ordinary process until a FREEZE statement in the program is encountered. The FREEZE statement changes an ordinary process into a server library process. While the process is frozen, it typically does little or no work on its own; it simply remains present in memory so that client processes can link to it and use the exported objects.
Duration of the Freeze
Eventually, a server library process ceases to be a library and resumes execution as an ordinary process. The duration of the library state is specified by one of three FREEZE options. In most languages, you specify the FREEZE option in the FREEZE statement. The following are all the options supported by the system. Not all options are available in all languages.
A private library is always frozen temporarily, despite the option on the FREEZE statement; however, a FREEZE with the CONTROL option still executes the Control procedure.
-
The server library program ceases execution and remains available as long as clients of the library remain. A temporary library that is no longer in use resumes execution and ceases to be available for linkage. The export objects declared in the server library process do not become available to client programs again; attempts to link cause another instance of the server library to be initiated. Using the TEMPORARY option prevents memory space from being occupied by a server library that is not in use.
Links to connection libraries declared within the library, do not keep the library frozen.
-
The server library program ceases execution and remains available unless interrupted by an operator command or another program action. (Resuming a permanent library is discussed under Thawing and Resuming Server Libraries later in this section.) It is advisable to make a server library permanent if it is frequently used; the PERMANENT option prevents the system from having to re-create the server library repeatedly during the day. It is also advisable to make a server library permanent if it accesses a database or other files that need to be kept open.
-
The program is made available as a server library, and control passes to a local procedure in the library called the control procedure, where execution continues. The control library changes into a temporary library when the control procedure is exited.
The CONTROL option makes it possible for a server library to decide when to resume itself. The CONTROL option is available in ALGOL and, implicitly, in FORTRAN77. The programmer typically includes statements in the control procedure to prevent it from being exited until certain conditions are met.
In order to get the expected response, program the library to periodically check the values of its LIBRARYSTATE and LIBRARYUSERS task attributes. If the duration bit (bit 27) in the LIBRARYSTATE attribute is reset, and the value of LIBRARYUSERS is zero, the library is expected to exit the CONTROL procedure as soon as possible. Library linkages to this library are not initiated. The MCP linker waits for the library to resume normal execution before initiating a new instance of the server library.
The library’s EXCEPTIONEVENT is caused by the MCP upon the transition to a temporary duration and when the last library user delinks.
After a server library unfreezes, it cannot execute another FREEZE statement in order to become a library again.
Freezing COBOL74 Libraries
FREEZE statements are not used in COBOL74 libraries. Programs written in this language freeze automatically if they are initiated through the library linkage mechanism. (This method of initiation is discussed under Initiating Server Library Processes later in this section.) You can use the TEMPORARY compiler control option to specify that the library freeze should be temporary. If you do not use the TEMPORARY option, the library sharing option determines the type of freeze. A sharing value of SHAREDBYALL results in a permanent freeze, and sharing values of PRIVATE or SHAREDBYRUNUNIT result in a temporary freeze. For further information about the sharing option, refer to Controlling Server Library Sharing later in this section.
Freezing C Libraries
The FREEZE statement is also not used in C libraries. A C library freezes automatically if it is initiated by the library linkage mechanism. You can use the DURATION compiler option to specify whether it should be a temporary, permanent, or control freeze. If a temporary or permanent freeze is specified, the library freezes immediately after the function main finishes executing. If a control freeze is specified, the function main executes as the control procedure.
Displaying Frozen Libraries
You can use the LIBS (Library Task Entries) system command to list the frozen library processes on the system. The list includes permanent, temporary, and control libraries.

