Chapter Contents |
Previous |
Next |
Sharing extern Variables among Load Modules |
If the
rent
or
rentext
compiler option is used, the compiler generates
an object code data type called a pseudoregister for each
extern
variable. If the
norent
compiler option is used, the compiler generates a pseudoregister
only for
extern
variables declared as
__rent
or whose names begin with an
underscore (such as
_options
). When the program is linked, the linker
assigns an offset to each pseudoregister and accumulates the total length.
At execution time, storage is dynamically allocated for all the pseudoregisters
in the load module. This storage is known as the pseudoregister vector.
In a program consisting of several load modules, each
load module has its own pseudoregister vector that is independent of the pseudoregister
vector of any other load module. This means that, in general,
extern
variables cannot
be shared between load modules.
However, certain
extern
variables need to be available
in all the load modules in a multi-load-module program. An
extern
variable of this
sort is known as a global
extern
. During dynamic loading, the loadm
function copies the values of the global extern from
the pseudoregister vector of the main load module to the psuedoregister vector
of the newly loaded module. Of course,
loadm
must be able to determine the
length and offset of each global
extern
both in the calling and called load modules.
This copy takes place only when the load module is loaded. Changes in the
value of the global
extern
after that point are not reflected back to
any other load module.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.