Chapter Contents

Previous

Next
The CMS GENCSEG Utility

Introduction

GENCSEG is a utility program for VM and CMS users that installs LOADLIB members in a Discontiguous Saved Segment (DCSS), hereafter referred to as a segment. Once installed, these members may be dynamically loaded by using the addsrch and loadm functions.

There are several reasons for using the GENCSEG utility. For example, programs that reside in a segment can be attached outside of the virtual machine's address range and, therefore, do not occupy memory within the virtual machine. Also, several users can share a copy of the segment. Further, since dynamic loading from a segment uses CP to fetch load modules, this type of installation is useful for programs that rely heavily on dynamic loading.

The GENCSEG utility operates as follows. First, GENCSEG accumulates a list of LOADLIB members. The next step is to determine the address range of the segment. Next, GENCSEG allocates a directory space and then begins to load the members in sequential order. As the members are loaded, their names are added to the directory. By default, the members are added sequentially, but GENCSEG provides parameters to specify load order, alignment, and spacing. The load address for the first member always begins immediately following the directory. The load address is then updated according to requested alignment and other options.


How Dynamic Loading Uses a Segment

The loadm function is used to dynamically load external load modules. Under CMS, loadm searches for the load module in several locations. The search is controlled by the addsrch function, which defines a set of locations where dynamically loaded modules can be found. The CMS_DCSS argument to addsrch specifies that modules can be found in a segment that has been created by GENCSEG.


The Segment Installation Process

A user with CP class E privileges can create and maintain new segments. Once a segment is defined or available, you can use GENCSEG to install members of one or more LOADLIBs into a single segment. The installation can be controlled by GENCSEG parameters that specify which members are to be installed, the names of the LOADLIBs to be used, and the order in which the members are to be installed.

GENCSEG always loads the members in your virtual machine, creating an image of the segment to be saved. This means that GENCSEG must be invoked in a virtual machine that has enough virtual storage defined to contain the entire segment, plus the memory required by GENCSEG to operate and the memory required by CMS. Before installing any members, GENCSEG initializes the segment image by writing binary 0s into the entire image area.

GENCSEG always assumes that the segment is designated as shared and protected under VM/SP. In a VM extended architecture system, this implies that the SR parameter is used in the DEFSEG command. After the image area has been set to 0, GENCSEG performs the equivalent of the SETKEY command, setting all storage keys in the segment image to key 0. This ensures that the code and data in the segment do not become corrupted during use. Since the code and data will reside in protected memory, the code must be reentrant. Non-reentrant code in a shared segment causes protection exceptions when executed. Use the SAS/C Compiler option rent to allow reentrant modification of static and external variables. See Compiler Options.

The loadm function searches for modules in a segment by reading a directory in the segment itself. This directory is created by GENCSEG during the installation process and begins at the first address in the segment. There is one entry in the directory for each member or alias installed in the segment.

GENCSEG saves the segment name and the current date and time in the first 16 bytes of the directory. The directory is terminated by an entry containing all binary 1s. Each directory entry is four words long. The first two words contain the name of the member or alias. The third word contains the address of the module entry point. The fourth word is all binary 0s and is reserved for use by the library.

The GENCSEG load parameters LOADLIB, ALIGN, PAGE, and SPACE control the installation process. These parameters are processed from left to right in the order they are entered on the command line. Upon invocation, GENCSEG initializes the segment and then begins processing the load parameters.

As members are loaded, GENCSEG maintains the value of the next available address in the segment. This value, called the load address or loadaddr, has an initial value equal to the first address following the segment directory. After each member is loaded, loadaddr is incremented by the size of the member. The ALIGN, PAGE, and SPACE parameters can be used to modify the value of loadaddr. However, loadaddr cannot be decremented, and at no time can the value of loadaddr become larger than the last address defined in the segment. If this occurs, GENCSEG terminates with a diagnostic message, and the segment is not saved.

GENCSEG installs a LOADLIB member by relocating the code and data based on loadaddr and creating a segment directory entry for the member. This process is repeated until all the members specified are installed. GENCSEG then issues a SAVESYS command for the segment.

As the installation proceeds, GENCSEG types a variety of diagnostic messages to the terminal. These messages report on the parameters being used, the state of the virtual machine, where the members are being loaded, and how many pages are used. GENCSEG also issues diagnostics when something unexpected occurs or when it is unable to continue the installation.

When all of the load parameters are processed (and no errors have occurred), GENCSEG invokes the CP SAVESYS (under VM/SP) or SAVESEG (under VM/XA or VM/ESA) command to save the segment image into DASD storage. The SAVESYS command must be issued from a userid with a CP privilege class of E. If the userid does not have CP class E privileges, the command fails and the segment is not saved.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.