Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 35
Transferring Data Between an Extended Data
Segment and a File
SEGMENT^ID := 1;
SIZE := 8000D;
MAX^SIZE := 64000D;
ERROR := SEGMENT_ALLOCATE_(SEGMENT^ID,
SIZE,
!swap^file:length!,
ERROR^DETAIL,
!pin!,
!segment^type!,
BASE^ADDRESS[I],
MAX^SIZE);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
.
.
ERROR := RESIZESEGMENT (SEGMENT^ID, MAX^SIZE);
IF ERROR <> 0 THEN ...
See the Guardian Procedure Calls Reference Manual for complete details of the
RESIZESEGMENT procedure.
Transferring Data Between an Extended Data Segment and a File
Transferring data between extended data segments and a file is like transferring data
between the TNS user data segment and a file. However, you must use only
procedures with the suffix “X” (for example, READX or WRITEX).
To improve the performance of I/O that involves extended data memory, you can use
SETMODE function 141 to transfer larger blocks of data at once.
The following paragraphs discuss both the procedures that perform I/O with extended
data segments and SETMODE 141. For complete details on these procedures, see
the Guardian Procedure Calls Reference Manual.
Using I/O Procedure Calls With Extended Data Segments
I/O procedures such as READ, READUPDATE, WRITE, and so on cannot access data
outside the TNS user data segment or, in native processes, the globals-heap and stack
segments. To transfer data between extended data segments and disk files or
processes, you must use the I/O procedures whose names end with the letter “X.”
The I/O procedures that can access extended data segments are READX,
READUPDATEX, REPLYX, WRITEX, WRITEREADX, WRITEUPDATEX,
READLOCKX, WRITEUPDATEUNLOCKX, and AWAITIOX. These procedures are
similar in function to their counterparts for nonextended data segments; however, these
procedures allow the I/O buffer to be in either an extended data segment or the TNS
user data segment.
Note. RESIZESEGMENT is a resource-intensive procedure. You should therefore avoid
frequent calls to this procedure. A general guideline is to call RESIZESEGMENT only when
changing the size of a segment by more than 128 K bytes. Resizing a segment by less than
20% should also be avoided.