NonStop S-Series Server Description Manual (G06.24+)
Instruction Processing Environments
HP NonStop S-Series Server Description Manual—520331-003
5-8
Sharing of Code and Data Segments
Sharing of Code and Data Segments
Code segments can be shared. That means that any number of processes can be
fetching and executing instructions from the same object code segment. The operating
system keeps track of which processes are using which segments. When the final
process among several that are using a given code segment ceases to exist, that code
segments can (and will) be deallocated by the operating system.
A notable example of sharing code segments is the system library, which is a set of
code segments that is shared by all processes existing in a given processor. Although
there is only one copy of the system library in the processor, each process can access
the library as part of its own user space in virtual memory.
The data stack segment (whether main stack, TNS stack, privileged stack, or Debug
stack) holds data that must be private to each individual process, as does the global
data segment of a native process. Stack data includes the call/return stack chain of
activation records that retains the historical state of the process.
Logical segments that the process establishes with a SEGMENT_ALLOCATE_
procedure call can be shared—if they are declared to be shareable when they are
allocated. (The disk file for a read-only logical segment can also be shared by
processes existing in different processors.) In this sense they are like files but, unlike
files, logical segments (both selectable and flat) form a part of each process’s memory
space.
Figure 5-4 shows an example of three processes (A, B, and C), each with its own
private data stack segment but (to some extent) sharing code segments and logical
segments. The shading indicates those segments that are actually shared. Although
these segments appear in the address space of each process sharing them, there is in
fact only one copy of each.
Processes A, B, and C (like all processes) share the system library segments, here
labeled K in each process’s user space. Processes B and C share some other object
code segments, labeled N. Processes A and C share a logical segment, labeled X.
Process B does not share its logical segment, labeled Y.
When segments are shared by two or more processes, the same pages of data or
code are used by all of them, and the addressing tables (SPTs and Vsegs) that
designate them are also shared. The operating system keeps track of which
processes share each segment (and at which addresses, which can vary from process
to process for a shared flat segment).