Gets shared memory segments.
Standard C Library (libc.a)
#include <sys/shm.h> int shmget (Key, Size, SharedMemoryFlag) key_t Key; size_t Size int SharedMemoryFlag;
The shmget subroutine returns the shared memory identifier associated with the specified Key parameter.
The following limits apply to shared memory:
|Key||Specifies either the IPC_PRIVATE value or an IPC key constructed by the ftok subroutine (or by a similar algorithm).|
|Size||Specifies the number of bytes of shared memory required.|
|SharedMemoryFlag|| Constructed by logically ORing one or more of the following values:
A shared memory identifier, its associated data structure, and a shared memory segment equal in number of bytes to the value of the Size parameter are created for the Key parameter if one of the following is true:
Upon creation, the data structure associated with the new shared memory identifier is initialized as follows:
Upon successful completion, a shared memory identifier is returned. Otherwise, the shmget subroutine returns a value of -1 and sets the errno global variable to indicate the error.
The shmget subroutine is unsuccessful if one or more of the following are true:
|EACCES||A shared memory identifier exists for the Key parameter, but operation permission as specified by the low-order 9 bits of the SharedMemoryFlag parameter is not granted.|
|EEXIST||A shared memory identifier exists for the Key parameter, and both the IPC_CREAT and IPC_EXCL flags are set in the SharedMemoryFlag parameter.|
|EINVAL||A shared memory identifier does not exist and the Size parameter is less than the system-imposed minimum or greater than the system-imposed maximum.|
|EINVAL||A shared memory identifier exists for the Key parameter, but the size of the segment associated with it is less than the Size parameter, and the Size parameter is not equal to 0.|
|ENOENT||A shared memory identifier does not exist for the Key parameter, and the IPC_CREAT flag is not set in the SharedMemoryFlag parameter.|
|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 meet the request.|
|ENOSPC||A shared memory identifier will be created, but the system-imposed maximum of shared memory identifiers allowed will be exceeded.|
This subroutine is part of Base Operating System (BOS) Runtime.
The ftok subroutine, mmap subroutine, munmap subroutine, shmat subroutine, shmctl subroutine, shmdt subroutine.
List of Memory Manipulation Services, Subroutines Overview, Understanding Memory Mapping in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.