Guardian Procedure Calls Reference Manual

segment is a flat segment. The base-address parameter of the SEGMENT_USE_
Procedure (page 1298) also returns the base address of a segment.
Use the usageFlags member of the segmentInfo struct reported by the
SEGMENT_GETINFOSTRUCT_ Procedure (page 1291), or the usage-flags parameter
of the SEGMENT_GETINFO[64]_ Procedures (Superseded by
SEGMENT_GETINFOSTRUCT_ Procedure) (page 1287).
Flat segments and TNS user libraries
A user library in a TNS process cannot maintain its own private global variables, so it has no
way to retain the address of a flat segment allocated for its private use. A library can use a
fixed segment ID when allocating a segment and then determine the base address in subsequent
invocations by passing the same segment ID to the SEGMENT_USE_ Procedure (page 1298).
Alternatively, a library can return the base address to its client and have this address returned
as a parameter in each library call.
Examples
C Example
/* C example sharing a 64-bit segment by PIN with read-only access */
#include <kmem.h>
segid_t segID;
short error, detail;
unsigned short pin;
void _ptr64 *baseAddr;
error = SEGMENT_ALLOCATE64_ ( segID,
, /* size */
, , /* filename, length */
&detail,
pin,
SEGMENT_TYPE_READONLY,
&baseAddr);
TAL Example
error := SEGMENT_ALLOCATE_ (segment^id, seg^size);
! TAL/pTAL call to create a selectable segment
error := SEGMENT_ALLOCATE_ (segment^id, seg^size, , , , , , 2);
! TAL/pTAL call to create a (32-bit) flat segment
error := SEGMENT_ALLOCATE64_ (17, 5368709120F);
! pTAL call to create a 5-gigabyte (64-bit) flat segment
error := SEGMENT_ALLOCATE_ (segment^id, , , error^detail,
pin);
! allocates a shared selectable segment, using the PIN
! method, which is shared with the segment given by
! segment^id in the process identified by pin.
error := SEGMENT_ALLOCATE_ ( segment^id, , filename:length,
error^detail, , 2 );
! allocates a shared segment using the filename
! method
Related Programming Manual
For programming information about the SEGMENT_ALLOCATE[64]_ procedures, see the Guardian
Programmer's Guide.
SEGMENT_ALLOCATE[64]_ Procedures 1271