FREEZE Statements in Library Procedures

At least one EXPORT declaration must appear in the same block as the FREEZE statement. The procedures affected by a FREEZE statement are the procedures that appear in EXPORT declarations in the same block as the FREEZE statement. After the FREEZE statement is executed, these procedures are library entry points.

The PERMANENT and TEMPORARY specifications of the FREEZE statement control the permanence of the library. A permanent library remains available until it is discontinued. A temporary library remains available as long as there are users of the library. A temporary library that is no longer in use unfreezes (thaws) and resumes running as a regular program. When a library unfreezes, it cannot execute another FREEZE statement in an attempt to become a library again.

The CONTROL specification of the FREEZE statement controls the nature of the freeze. The program is set up as a permanent library, but after the freeze operation has been performed, control is transferred to the specified procedure, known as the control procedure. The procedure must be untyped and must have no parameters.

Once the control procedure is in control, the library can keep track of the number of its users through the task attribute LIBRARYUSERS.

When the control procedure is exited, the library unfreezes if there are no users. If there are users, the library becomes an ordinary library, and a warning message is issued. A control frozen library can prevent the warning message from being issued and prevent the linkage of new users by changing the value of the task attribute STATUS to VALUE(GOINGAWAY). This status change causes the library to unfreeze and resume execution as a normal program as soon as possible. For further information on the value setting for the STATUS attribute, refer to the Task Attributes Programming Reference Manual.

Because a 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 in any block that contains an EXPORT list.

If a calling program causes a library to be initiated and this library does not execute a FREEZE statement (if, for example, it was not a library program and thus had no FREEZE statement), then the attempted linkage to the library entry points cannot be made, and the calling program is discontinued. For more information on libraries, refer to Library Facility.