Open System Services System Calls Reference Manual (G06.25+, H06.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 identi
er. This key is
then passed to the shmget() function, which returns a shared memory identier. The shared
memory identier is then used in calls to the shmat() and shmctl() functions.
Uniqueness of Identiers
The system recycles no-longer-used shared memory identi
ers after a long time elapses.
Swap File
A shared memory segment is shared through a Guardian environment swap le so that its data
remains intact even when no processes include it in their virtual address space. This swap le is
temporary. It resides on the local HP NonStop node on the same volume as the swap le for the
stack segment of the process creating the shared memory segment. If the stack segment is
resident, the code segment of the process is used instead.
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 les
If the disk process controlling the swap le fails, the system monitor causes any process with the
corresponding shared memory attached to terminate abnormally. Thereafter, a process cannot
successfully call either the shmget() or shmat() function using the associated shared memory
identier. When either function is called, the shared memory segment and its identier are
removed from the system-maintained shared memory table.
Valid Segment Sizes
A shared memory segment can contain up to 4 regions. A region is 32 megabytes (MB). A
shared memory segment can therefore be 1 byte to 128 MB in size.
Number of Shared Segments and Identiers
The maximum number of shared memory identiers 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 Identiers
A shared memory identier remains allocated until it is removed. An allocated shared memory
identier is not removed when the last process using it terminates. The user must remove allo-
cated shared memory identiers that are not attached to processes to avoid wasting shared
memory resources.
The status of shared memory identiers can be checked with the ipcs command. Shared memory
identiers can be removed using the ipcrm command. The associated shared memory segment
and data structure are removed only after the nal detach operation.
Shared Memory Use Between Environments
Guardian environment processes cannot use OSS environment function calls for access to OSS
shared memory segments. Similarly, OSS environment processes cannot use OSS environment
function calls for access to Guardian environment shared memory segments. However, OSS
environment processes can allocate a Guardian environment shared memory segment and mani-
pulate it using Guardian environment procedure calls. A Guardian environment process and an
OSS environment process can share resources through the Guardian environment shared
527186-003 Hewlett-Packard Company 755