VIRTUAL MEMORY AND SEGMENTATION [ MPE Segmenter Reference Manual ] MPE/iX 5.0 Documentation
MPE Segmenter Reference Manual
VIRTUAL MEMORY AND SEGMENTATION
Because memory capacity is limited, all computer systems need some method
of separating code and data into units and moving these units in and out
of main memory as they are needed. HP has developed a solution based on
"virtual memory" and "segmentation."
Virtual Memory
Virtual memory is a memory management scheme which uses disc storage as
secondary memory, allowing the system to reference a virtual memory space
many times larger than main memory so that you can write programs much
larger than the physical memory available could contain. As programs are
executing, only those pieces of each program required at a particular
time actually reside in main memory. The other related segments remain
on disc until they are in turn required. Then the system makes space
available for them and brings them into main memory. Thus, segments
within a program which are idle do not take up space along with those
that are actually executing, possibly preventing the loading of code
segments needed for another program. This design allows the HP 3000 to
run multiple programs concurrently.
The process of bringing code segments from disc memory to main memory is
called "swapping". Excessive swapping slows down program execution and,
in general, makes heavy demands on system resources. The number of times
swapping occurs depends on how efficiently a program is segmented with
respect to:
* Program logic. If procedures in one segment frequently call
procedures within another segment, the operating system may have to
make frequent swaps and transfers of control.
* Memory size available. If segments are too large, segments which
should be in main memory together because of their logical relation
will have to be swapped in and out. If segments are uneven in size,
the system will spend much time seeking appropriate space for each
segment.
The HP 3000 allows you to tailor segmentation to the logic of your
program and the memory space available in your system.
Segmentation
Segmentation is the separation of code into various-sized pieces, or
"segments," according to logical, rather than physical, considerations.
It is the most efficient means of implementing the HP 3000's virtual
memory design. The HP 3000 can follow system defaults to segment your
program. You can also handle the segmentation yourself, using embedded
control statements to the compiler or commands to the Segmenter, which is
a subsystem of the MPE operating system. Several features contribute to
the flexibility of the segmentation design.
SEPARATION OF CODE AND DATA. Code consists of the executable
instructions that make up a program or subprogram. Data is the values
and arrays used by the program or subprogram. In most computer systems,
prepared programs consist of intermixed code and data. For example,
within a subprocedure there are program locations reserved by the
compiler for the return addresses of other subroutines and space set
aside for the storage of local variables.
The HP 3000 system separates programs into those elements that do not
need to be altered and those that do. Thus, prepared HP 3000 programs
consists of separate segments for code and for data. The two are never
intermixed (with the exception that program constants may be present in
code segments). Since data changes dynamically during execution, it must
be written back to disc storage after each modification. Code, on the
other hand, is unchanging during execution and needs only to be read into
main memory, never written back to disc. When a code segment is no
longer needed, it is simply overlaid by another code segment. Should the
segment be needed again, another copy can be read in from the original on
disc.
Because it separates code from data, the HP 3000 reduces the amount of
material that must be swapped. If code were intermixed with data, the
system would have to swap material that had not changed along with
material that had.
Although code is not modifiable during execution, you can use the
Segmenter to create alternate versions of programs from the compiled
source code.
SHARABLE CODE ENVIRONMENT. Because the HP 3000 maintains code and data
in strictly separate environments, and because code is non-modifiable
during execution, HP 3000 code is sharable among many users. HP 3000
code is also re-entrant: when a program is interrupted during execution
of a code segment and another user's execution needs the same segment,
that segment can be used, is completely protected against modification,
and will be returned intact to the previous user's execution.
Hewlett-Packard's design for code handling uses main memory with optimum
efficiency.
VARIABLE SEGMENT SIZE. In the HP 3000 design, segment sizes are not
fixed, as are the code and data entities in some designs, but vary
according to the logical needs of each unit of code or data: code
segments may be up to 16,383 words in length, and data segments may be up
to 32,767 words in length. Thus, a particular subprogram can always be
contained within one segment rather than arbitrarily divided between two
physical pages. The amount of swapping necessary is reduced, and memory
space is not wasted with partially-filled pages.
Segmentation is one of the key features in the design of the HP 3000.
Good segmentation can enhance your program's execution efficiency as well
as lessening the overall load on system resources.
Although the management of code segments (i.e., the transfer of segments
from disc to main memory) is completely transparent to your program, the
steps you take to control segmentation affect how efficient that
management can be. The Segmenter subsystem is a powerful tool which
allows you to manipulate code and to tailor segmentation, assuring
efficient individual programs and effective use of your system's
resources.
MPE/iX 5.0 Documentation