HP-UX Reference (11i v2 03/08) - 2 System Calls (vol 5)
s
shmget(2) shmget(2)
System V Shared Memory Under Adaptive Address Space
Itanium-based platforms have the capability to create two types of processes: MGAS (Mostly Global
Address Space), which is the default, and MPAS (Mostly Private Address Space). See ld (1) and chatr (1).
If 64-bit MPAS and 64-bit MGAS processes want to share a mapping among themselves without incurring
the cost of aliasing, then (shmflg &
IPC_GLOBAL) should be ‘‘true’’, but (shmflg &
IPC_SHARE32)
should be ‘‘false’’. 64-bit MPAS processes should also specify the
IPC_GLOBAL flag to the shmat(2) call.
Such a mapping cannot be shared with 32-bit MGAS processes.
See the Adaptive Address Space Whitepaper for details.
EXAMPLES
The following call to
shmget() returns a unique shmid for the newly created shared memory segment
of 4096 bytes:
int myshmid;
myshmid = shmget (IPC_PRIVATE, 4096, 0600);
RETURN VALUE
Upon successful completion, a non-negative integer, namely a shared memory identifier, is returned.
Otherwise, a value of −1 is returned and
errno is set to indicate the error.
ERRORS
shmget() fails if any of the following conditions are encountered:
[EINVAL] size is less than the system-imposed minimum or greater than the system-imposed
maximum.
[EINVAL] A shared memory identifier exists for key but is in 64-bit address space and the pro-
cess performing the request has been compiled as a 32-bit executable. In order to
avoid receiving this error, both
IPC_SHARE32 and IPC_CREAT must be set in
shmflg by the 64-bit processes upon segment creation.
[EACCES] A shared memory identifier exists for key but operation permission (see glossary (9))
as specified by the low-order 9 bits of shmflg would not be granted.
[EINVAL] A shared memory identifier exists for key but the size of the segment associated
with it is less than size and size is not equal to zero.
[ENOENT] A shared memory identifier does not exist for key and (shmflg &
IPC_CREAT)is
‘‘false’’.
[ENOSPC] A shared memory identifier is to be created but the system-imposed limit on the
maximum number of allowed shared memory identifiers system wide would be
exceeded.
[ENOMEM] A shared memory identifier and associated shared memory segment are to be
created, but the amount of available physical memory is not sufficient to fill the
request.
[ENOMEM] A shared memory segment with
IPC_CREAT or IPC_GLOBAL specified was to be
created; however, there is not enough space in the global quadrant.
[EEXIST] A shared memory identifier exists for key but ( (shmflg &
IPC_CREAT)&&(shmflg
& IPC_EXCL) ) is ‘‘true’’.
SEE ALSO
chatr(1), ld(1), ipcrm(1), ipcs(1), mpctl(2), shmctl(2), shmop(2), ftok(3C), Adaptive Address Space White-
paper .
STANDARDS CONFORMANCE
shmget(): SVID2, SVID3, XPG2, XPG3, XPG4
HP-UX 11i Version 2: August 2003 − 2 − Hewlett-Packard Company Section 2−−355