Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 6
Managing the Native User Data Areas
the values saved on the stack so that processing continues at the address immediately
following the call to the procedure that just returned. The S register points to the last
location of the local variables of the main procedure.
The TNS user space also includes a main stack and a priv stack, which are used
when a TNS procedure calls a TNS/R native procedure. When a nonprivileged native
procedure is called, execution switches to the main stack. When a privileged native
procedure is called, execution switches to the priv stack. The main and priv stacks are
described later in this section under Managing the Native User Data Areas.
See the appropriate system description manual for a complete description of how the
data stack, main stack, and priv stack work.
Using the Upper 64K Bytes of the Data Segment
Only the first 64K bytes of the user data segment can be used by the data stack. To
access the upper 64K bytes, you must manage the space yourself using 16-bit
memory pointers.
For example, in an application written in TAL, you could access an array starting at the
beginning of the upper 64K bytes as follows:
INT .A := %100000;
.
.
X := A[4];
X is assigned the value of the fifth word of the upper 64K bytes.
Managing the Native User Data Areas
Data for TNS/R native processes is allocated in the following data segments:
A globals-heap segment, containing global data and, for C and C++ programs, a
user heap. This segment provides up to 128 megabytes of data storage.
A main stack segment, containing the stack frames for nonprivileged procedure
calls.
A priv stack segment, containing the stack frames for privileged procedure calls.
Zero or more SRL data segments used for global data owned by shared run-time
libraries (SRLs). Each SRL owns an SRL data segment.
A process file segment (PFS), used by the operating system for file buffers and
other internal data.
Data for a TNS/E native process is allocated into the following data segments:
A globals-heap segment, containing program global data and, optionally, a heap
A main memory stack for nonprivileged TNS/E native procedures
A privileged memory stack for privileged procedures