In large programs it may be advantageous to make individual program segments shareable if they are to be accessed by several users (tasks).
For this, the following control statement must be specified at compilation time:
COMOPT GENERATE-SHARED-CODE=YES
or
SHAREABLE-CODE=YES
in the MODULE-GENERATION parameter of the COMPILER-ACTION option
The compiler then generates two object modules, one of which contains the nonshareable section and the other the shareable section of the object. These are referred to in the following as the “nonshareable” and “shareable” module, respectively. The shareable and nonshareable modules can themselves be linked into prelinked modules.
The shareable modules must be stored in a PLAM library either directly by the compiler (via a COMOPT MODULE statement or the SDF option MODULE-LIBRARY) or by means of the LMS utility routine (see “LMS” manual [11]).
All nonshareable sections of a program are loaded separately for each task and user into class 6 memory.
Program systems with shareable modules can only be called using DBL. The call always uses the name of the nonshareable (data) module. This contains external references to its shareable code module as well as to any other nonshareable modules.
Sample call:
/SET-TASKLIB $.SYSLNK.CRTE ———————————————————————————————————————(1) /START-PROGRAM *MOD(library,element) —————————————————————————————(2)
(1) | The SET-TASKLIB command is used to assign the library that contains the COBOL runtime system. |
(2) | element is the name of the data module or prelinked module which must contain at least the nonshareable section of the main program. library is the library containing the user-written modules. |
The following figure illustrates program runs with and without shared code.
Figure 3: Shared code