Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 27
Allocating Extended Data Segments
The difference between the temporary swap file and the permanent swap file is that
when the extended data segment is later deallocated, the permanent swap file remains
on disk and can be accessed after the segment is deallocated. It can be used, for
example, to set the initial data in another segment that later uses it as a swap file; thus,
it can serve as a record of a past state. In contrast, the data in a temporary swap file is
lost once you deallocate the extended data segment.
The following example allocates a flat segment with a permanent swap file:
SEGMENT^ID := 4;
SIZE := 8000D;
OPTIONS.<14> := 1;
FILENAME ':=' "$PROGRAM.SWPFILES.MYPROG" -> @S^PTR;
FILENAME^LENGTH := @S^PTR '-' @FILENAME;
ERROR := SEGMENT_ALLOCATE_(SEGMENT^ID,
SIZE,
FILENAME:FILENAME^LENGTH,
ERROR^DETAIL,
!pin!,
!segment^type!,
BASE^ADDRESS,
!max^size!,
OPTIONS);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
You must specify a file name if you intend to use the file-name method of segment
sharing.
Specifying the Attributes of the Extended Data Segment
So far this section has described how to allocate extended data segments with default
attributes: that is, private, read/write, and nonextensible. If you need segments that
are shared with another process, are read-only, or are extensible, then you need to
specify the segment-type parameter. The following example specifies an extensible
data segment. The value for the segment-type parameter,
ZSYS^VAL^SEGALLOCTYPE^EXTENSBL, is taken from the ZSYSTAL file:
SEGMENT^ID := 0;
SIZE := 8000D;
SEGMENT^TYPE := ZSYS^VAL^SEGALLOCTYPE^EXTENSBL;
ERROR := SEGMENT_ALLOCATE_(SEGMENT^ID,
SIZE,
!swap^file^name:length!,
ERROR^DETAIL,
!pin!,
SEGMENT^TYPE,
BASE^ADDRESS);
IF ERROR <> 0 THEN ...
For a complete list of segment-type values and other details about the
SEGMENT_ALLOCATE_ procedure, see the Guardian Procedure Calls Reference
Manual.