Open System Services Programmer's Guide

Segment sharing is specified using an identifier called shmid, returned by shmget(), and passed
to shmat(). Permission to share the segment is based on OSS protection mechanisms: the creator
specifies whether the segment can be shared by the same user, the user group, or anyone.
For information about the set of shm*() functions, see the Open System Services System Calls
Reference Manual in the NTL.
Guardian Memory Segments
The SEGMENT_ALLOCATE_ Guardian procedure can create and share either flat or selectable
segments. By default, it establishes a selectable segment. On servers running H06.20 and later
H-series RVUs, or J06.09 and later J-series RVUs, SEGMENT_ALLOCATE64_ provides a superset
of SEGMENT_ALLOCATE_ facilities. By default, SEGMENT_ALLOCATE64_ establishes a flat
segment in 64-bit address space; parameters can specify a 32-bit flat segment or a selectable
segment, (which is always in 32-bit address space).
Both procedures can create segments backed either by the Kernel Managed Swapspace Facility,
KMSF, or by individual temporary or permanent files. Both procedures support sharing of Guardian
segments, specified by file name or by (segment ID and) PIN.
For share-by-PIN, the caller specifies the PIN of a process (in the same processor) to share the
segment in that process using the same segment ID. Permission is based on the process-access-ID
attributes of the two processes.
For share-by-filename, the caller specifies the file name of the backing file for the segment; the
contents of the file are mapped directly into memory, and the file-backed memory segment is shared
among all processes allocating it. Permission is based on access attributes for the file and the
access ID of this process. If the segment is read-only, it can be shared by processes in multiple
processors, and the file can also be opened for reading. Otherwise, all processes sharing the
segment must be in the same processor, and the file cannot simultaneously be open for reading
or writing. Guardian segments shared by file name provide some of the same abilities of the
mmap() function, which is found in many UNIX and Linux systems. For more information, see
Memory Mapping in the Open System Services System Porting Guide.
Other procedures of interest for managing Guardian memory segments include:
ADDRESS_DELIMIT[64]_
MOVEX
SEGMENT_DEALLOCATE_
SEGMENT_GETINFO[64]_
SEGMENT_GETINFOSTRUCT_
SEGMENT_RESIZE_
SEGMENT_USE_
For information about these procedures, see the Guardian Procedure Calls Reference Manual in
the NTL.
Memory-Management Interoperability
Guardian and OSS processes can share memory segments with each other. Both Guardian and
OSS processes can call SEGMENT_ALLOCATE_ and related Guardian procedure calls: they can
share segments as described for SEGMENT_ALLOCATE_. On servers running J06.12 or later
J-series RVUs or H06.23 or later H-series RVUs, both Guardian processes and OSS processes can
call the OSS shared memory functions; they can share segments as described for shmget(). For
more information about these functions, see “Using Shared Memory” (page 189).
The shared memory segments created and managed by OSS shm*() functions are distinct from
segments created by the Guardian SEGMENT_ALLOCATE_ and related procedure calls. Both kinds
of segments can be created and shared, but one kind cannot be shared with the other.
164 Managing Memory