Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 41
Determining the Starting Address of a Flat Segment
SEGMENT^TYPE);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
Note that it is not necessary to specify the segment size, because the segment already
exists.
Considerations for Sharing a Flat Segment
Flat segments can be shared only with flat segments allocated with specific segment
IDs.
If you do not specify a base address, by default the system attempts to map the shared
segment starting at the base address specified in the original
SEGMENT_ALLOCATE_call (if that process still has the segment allocated, if not then
the address is selected from one of the other processes that shares the segment). If
the range of the requested segment is partially or completely overlapped in the current
process, then an error is returned. If option bit <9> is set to one and the base address
is not specified, then the system behaves the same as the default. However, instead
of returning an error if the range of the requested segment is partially or completely
overlapped in the current process, the system will attempt to allocate the segment at
any address within the flat segment space.
Considerations for Sharing a Selectable Segment
Selectable segments can be shared only with selectable segments.
HP recommends against using explicit selectable segments in TNS processes that use
the automatic compiler-generated selectable segment, especially in C, Fortran or
Pascal programs that use the (default) XMEM memory model. See Using Selectable
Segments in TNS Processes.
Determining the Starting Address of a Flat Segment
In certain situations, you may want to find out the starting address of a previously
allocated flat segment. For example, you may have a library routine that needs the
starting address of a flat segment that was allocated in a previous invocation of the
routine.
The starting address of a flat segment is returned by the SEGMENT_ALLOCATE_
procedure call that allocates the segment. To find out the starting address later in a
program, use the SEGMENT_GETINFO_ procedure. The following example returns
the base address of flat segment 3:
INT(32) .EXT SEG^PTR;
.
.
.
SEGMENT^ID := 3;
ERROR := SEGMENT_GETINFO_(SEGMENT^ID,
!segment^size!,
!filename:maxlen!,