Open System Services Programmer's Guide
Selectable Segments
Selectable segments all share the same address range; all selectable segments have the same
starting address (%2000000 or 0x80000). Thus, only one selectable segment is available to a
process at any given time. You select a segment—make a segment current—with the
SEGMENT_USE_ procedure. For information about using extended segments in application
programs, see the Managing Memory chapter in the Guardian Programmer’s Guide.
Native Processes
In a native process, all system-supplied segments are flat. The system provides a data segment for
the program’s global data and the 32-bit heap, and a segment for the instance data of each DLL
or SRL in the process that has global data. Optionally (specified at link time), TNS/E programs
and DLLs can have separate segments for constant and variable data. In a 64-bit TNS/E OSS
process (supported beginning with the H06.24 and J06.13 RVUs), the heap occupies a separate
segment in 64-bit address space.
There are also system-provided stack segments, a main stack for running procedures in user state,
and a priv stack for running procedures in privileged state (for example, portions of the operating
system). Other segments are supplied for system use; some in the process address space and others
that are global—visible to all processes.
TNS Processes
In the legacy TNS environment, the process has a User Data Segment of up to 128 KB at address
0, and often an automatic extended data segment of up to 127.5 MB. TNS OSS processes can
exist on TNS/R systems but not TNS/E systems. TNS OSS processes use the wide-data model
(ILP32): int, long, and pointer data types all occupy 32 bits. In TNS C, the wide-data model is
a variant of the large-memory model. TNS processes using other data models, or any Guardian
TNS processes, are of interest to OSS programmers only if they want to share data segments with
such processes. For information about the wide-data model and the large-memory model, see the
C/C++ Programmer's Guide for NonStop Systems in the NTL.
A process using the large-memory model has an automatic (compiler-generated) extended data
segment, with segment ID 1028, which holds the heap, most global and static data, and local
aggregate data. This segment is selected automatically and must remain selected to access this
data. Therefore, HP strongly discourages explicitly selecting other selectable segments in such a
process. For additional information, see Using Selectable Segments in TNS Processes in the
Guardian Programmer’s Guide.
On TNS/R and TNS/E systems, TNS processes also have native stack segments. These stacks are
used when the process transitions into native mode to invoke native procedures in the operating
system.
User-Created Segments
In addition to the segments provided automatically by the system, the user can cause explicit
segments to be created and shared. Separate mechanisms are supplied by Guardian and OSS
APIs.
OSS Shared Memory Segments
The following OSS functions manage flat shared-memory segments:
• shmget() – Creates a new segment or shares an existing one.
• shmat() – Attaches the segment to the process.
• shmdt() – Detaches the segment.
• shmctl() – Performs other actions on the segment, including removing it. The segment persists
until explicitly removed.
Native Processes 163