Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 16
Using (Extended) Data Segments
address-descriptor output parameter to obtain a set of flags that describe the
area.
The following example can be run in both the native and TNS environments. In the
TNS environment, the address of a local variable contained in the user data segment is
passed to ADDRESS_DELIMIT_. The procedure returns the addresses of the first
byte (HIGH^ADDR) and last byte (LOW^ADDR) of the user data segment, which are then
used to determine its size.
In the TNS/R native environment, the address of a local variable contained in the main
stack is passed to ADDRESS_DELIMIT_. The procedure returns the following:
The address of the last byte in the main stack in HIGH^ADDR. This is equal to
MAINSTACK^ORIGIN - 1D, where the MAINSTACK^ORIGIN process attribute
indicates the starting byte address of the main stack.
The current stack limit (the lowest-addressed byte allocated in the main stack
segment) in LOW^ADDR. (This limit can change as the stack grows during
execution.)
This example shows that the output addresses can be assigned either to a simple
variable (HIGH^ADDR) or to a pointer variable (LOW^ADDR).
INT LOCAL^VARIABLE;
STRING .EXT LOW^ADDR;
INT(32) HIGH^ADDR;
INT ERROR,
ERROR^DETAIL;
INT(32) SIZE;
.
.
.
ERROR := ADDRESS_DELIMIT_ ($XADR(LOCAL^VARIABLE),
@LOW_ADDR,
HIGH^ADDR,
! address^descriptor ! ,
! segment^ID ! ,
ERROR^DETAIL);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
SIZE := HIGH^ADDR - @LOW^ADDR + 1D; ! size in bytes of
! user data segment
Using (Extended) Data 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.
When the user data segment (TNS processes) or globals area (native processes) does
not provide enough data space for your process, you can make additional virtual
memory available to the process. Virtual memory is allocated as one or more