A Shareable Image Library in the BEPC Control System
C. Wang

J. Zhao

Institute of High Energy Physics, Chinese Academy of Sciences
P.O. Box 918-10, Beijing 100039, ChinaAbstract
The paper describes the method and procedure fordeveloping the shareable image library within the BEPCcontrol system.
1 Introduction
There are many application processes and object module
libraries of the BEPC control system in the VAX/VMS
environment. Each process must be linked to these object
module libraries to create an executable image (see figure1). When processing object modules, the linker has toresolve symbolic references, sort program sections into
image sections and initialize the image section contents,
total link processing time will increase , each processneeds to have its own copy of these modules, so eachprocess takes up more space in physical memory and moredisk storage. If these object modules can be linked into one
shareable image(see figure 2), the above mentioned
problems can be avoided.

objectmodulelibraries

application
objectmodules

Linkerapplication
programs

Figure 1. The executable images linked
to the object module libraries.
2 A shareable image library2.1 A shareable image
A shareable image is the product of a link operation. It is
not directly executable, that is, it cannot be executed bymeans of the DCL command RUN. To execute, ashareable image must first be included as input in a link
operation that produces an executable image of anapplication program. When that executable image is run,the shareable image is also activated by the imageactivator.
A shareable image file consists of an image header, one
or more image sections, and a symbol table, which appears
at the end of the file. The symbol table is, in fact, an object
module whose records contain definitions of universal
symbols in the shareable image. For a shareable image auniversal symbol is what a global symbol is for a module,
that is, it is a symbol that can be used to satisfy referencesin external modules.
Shareable images can provide the following benefits:• Reduce total linking processing time.
• Avoid relinking entire applications.
• Conserve disk space.
• Conserve physical memory.
• Reduce I/O paging.
• Implement memory-resident database.
2.2 Method of creating a shareable image
There are two means of creating a shareable image:• Declaring Universal Symbols.
• A transfer vector.
Here, we only discuss the second way for simplicity.
A transfer vector labels a visual register cell by a label,in which the next cell address of a visual register or a cell
displacement is contained. This second cell is a pointer tothe actual directive to receive control. That is to say, atransfer vector defines an entry point for each subroutine.
The reasons for using a transfer vector are as follows:• A shareable image may conveniently be modified andincreased.
• The other processes linked against a shareable image
need not be relinked.
A transfer vector must be written in MACRO. Specify
the .TRANSFER directive to declare the symbol which is
its argument, this symbol is a universal symbol by default.
The instructions are as follows:(1) .transfer F00; Begin transfer vector to F00(2) .mask F00; Store register save mask
(3) jump L^F00+2 ; Jump to routine
Whatever language the procedure is written in, thetransfer vector has to be specified as above. To ensure
upward compatibility, follow these guidelines whencreating a transfer vector:• Preserve the order and placement of entries in atransfer vector.
• Add new entries to the end of a transfer vector.
When including universal data in a transfer vector file,use padding to leave adequate room for future growth
between the end of the transfer vector and the beginning of

the list of universal data declarations.
A transfer vector is included in a link operation as anyother object module, the linker will automatically use thetransfer vector when specifying LINK/SHAREABLE toobject
modulelibraries

Linkerapplication
objectmodule(.obj)

shareableimagelibrary

Linkerapplication
program(.exe)

Figure 2. The executable images linked tothe shareable image library.
create a shareable image. The linker will link the object
modules with the transfer vectors and the object modules
contained in the shareable image. However, to ensure
upward compatibility, you must make sure that the transfer
vector always appears in the same location of the image.
The best way to accomplish this is to make the transfer
vector always appear at the beginning of the image by
forcing the linker to process it first. So, using theCLUSTER-option, put the transfer vector file in a named
cluster, so that the transfer vector will appear at thebeginning of the file. Besides, to enable images which arelinked against a shareable image to run with various
versions of the shareable image, you must specify theidentification number of the image by using theGSMATCH-option to achieve it.
3 The shareable image library in the BEPC controlsystem
The shareable image library is different from the object
module library, in which the symbol table of the shareable
image is placed. There are about 20 object module
libraries in the BEPC control system, which refer to eachother. Because all application programs must be linked tothese libraries to create executable images, it takes a longtime to link these programs. If one module is modified, allprograms, which refer the module, must be relinked. To
avoid these shortcomings, we create a transfer vector
which defines an entry for each object module. Then, if
you include the object module with the transfer vector in a
named cluster, these object module libraries are still
included in a link operation as input. When creating
shareable images, we found that the attributes of someprogram sections had to be reset. If you do not reset theshareable attribute for program sections which arewritable, you must INSTALL the shareable images to run
the program. The shareable attribute [SHR] determines
whether multiple processes have shared access to thememory. For example, if modules are data blocks, which
are declared as EXTERNAL in the subroutine, we use theLinker ′PSECT-ATTR′ command to fix up various
PSECT′s to make them shareable or read-only, etc. We
create one shareable image library, which is called
LIBSHR. We put shareable modules into this library. Allprograms only need to link to this library. When processing
the shareable image library, the linker will look for theentire symbol table in the library. So, all programs onlyreserve the address of their referred modules. Each
program takes up less space in physical memory and lessdisk storage. When applications are executed, referenced
modules will be modules from the shareable library.
Because the version number of the shareable image isnever changed, all programs linked with the old version of
the shareable image don′t need to be relinked whenmodifying or increasing modules of the library, but theshareable image needs to be relinked. When running theseprograms, the executable image with the old version of theshareable image can map to the new version of theshareable image.
Up to now, the shareable image library in the BEPC
control system has been setup. It proved to be safe andreliable when running. Using the shareable image
conserves disk space and reduces linker processing time. It
provides convenience for maintenance and running.
Acknowledgment
The authors wish to take this opportunity to thank Dr. J.
Smedinghoff, who gave us a lot of help. We would like tothank Prof. Huiying Luo and Wei Liu for their help.
References[1] 〈Open VMS Linker Utility Manual〉.
[2] J.Smedinghoff, Fermilab Accelerator,Internal Report.

Division