Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (s and S) shmget(2)
• It allows detection of attempts to reference shared memory segments in other processors.
Key Creation
The key represents a user-designated name for a given shared memory segment. Keys are usu-
ally selected by calling the ftok() function before calling the shmget() function. The ftok( )
function returns a key based on a path and an interprocess communications identifier. This key is
then passed to the shmget() function, which returns a shared memory identifier. The shared
memory identifier is then used in calls to the shmat() and shmctl() functions.
Uniqueness of Identifiers
The system recycles no-longer-used shared memory identifiers after a long time elapses.
Swap File
A shared memory segment is backed by Kernel-managed swap space so that its data remains
intact even when no processes include it in their virtual address space.
Processor or Disk Process Failures
If a processor fails, the following is lost:
• All information in the system-maintained shared memory table for that processor
• All shared memory segments for that processor
• All corresponding swap files
If the disk process controlling the swap space fails, the system monitor causes any process with
the corresponding shared memory attached to terminate abnormally. Thereafter, a process can-
not successfully call either the shmget() or shmat() function using the associated shared
memory identifier. When either function is called, the shared memory segment and its identifier
are removed from the system-maintained shared memory table.
Valid Segment Sizes
On servers running J06.12 or later J-series RVUs, or H06.23 or later H-series RVUs, there is no
configured limit to the size of an OSS shared memory segement. The size of the OSS shared
memory segment is limited by system resources only.
On servers running earlier J-series RVUs, earlier H-series RVUs, or G-series RVUs, a shared
memory segment can contain up to 128 megabytes (MB).
Number of Shared Segments and Identifiers
The maximum number of shared memory identifiers is determined by the maximum number of
processes allowed for the processor. This value cannot exceed the limit
SHMT_MAXENTRIES, which is currently set to 1000.
Cleaning Up Shared Memory Identifiers
A shared memory identifier remains allocated until it is removed. An allocated shared memory
identifier is not removed when the last process using it terminates. The user must remove allo-
cated shared memory identifiers that are not attached to processes to avoid wasting shared
memory resources.
The status of shared memory identifiers can be checked with the ipcs command. Shared memory
identifiers can be removed using the ipcrm command. The associated shared memory segment
and data structure are removed only after the final detach operation.
Use by OSS and Guardian Processes
The shared memory segments managed by the shm*( ) functions are distinct from segments
created by SEGMENT_ALLOCATE_ and related Guardian procedure calls. Both kinds of seg-
ments can be created and shared, but one kind cannot be shared with the other. The shared
memory identifier, shmid, is not a Guardian segid value.
527186-023 Hewlett-Packard Company 7−87