Open System Services Programmer's Guide

4 Managing Memory
The term memory management has broad scope. The phrase applies to the actions of the operating
system, which associates ranges of virtual addresses with physical addresses and with aggregations
of data. Memory management applies somewhat differently to the actions in the user environment,
including the run-time library.
Examples of operating-system actions include:
Establishing the memory environment of a process
Including segments of code and data for the program and any libraries it uses
Creating explicit data segments, some of which can exist beyond the context of a single
process
Examples of user-level actions include:
Explicit user-program actions such as allocating data areas from a heap
Implicit actions such as:
The placement of global and static variables
The automatic creation and placement of local variables
These implicit placements occur as the program and libraries are compiled and linked.
A key memory-management concept in the NonStop system is the segment, defined as a collection
of information identified and managed as an entity with consistent access and other properties.
Abstractly, a segment can exist independently of a process, but when associated with a process
it occupies a contiguous range of virtual address space.
The system automatically establishes segments for the global data of the program, instance data
of any native libraries, and text (code) segments for the program and libraries. In C/C++ and
some other languages, the system establishes a process heap.
NOTE: For information about memory layout on NonStop systems, see the Managing Memory
chapter in the Guardian Programmer’s Guide.
Flat, Selectable, and Extended Segments
The term “extended” is significant only in the context of TNS processes. The only nonextended
data segment in user address space is the TNS user data segment, and there are no nonextended
data segments in a native process. For information about TNS processes, see “TNS Processes
(page 163).
In the TNS architecture, extended data segments are selectable. Most segments on modern systems
are flat; however, the NonStop system continues to support selectable segments.
Flat Segments
Flat segments have distinct addresses. All flat segments allocated in a process are available to that
process simultaneously.
With the exception of the automatic extended data segment of TNS processes, described below,
all the segments allocated automatically by the system are flat.
NOTE: The adjective “flat” is applied to segments on NonStop systems only to mean “not
selectable.
162 Managing Memory