The shmget function returns a shared memory ID that it either created or was allowed to access.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state; PSW key 2, 8, or 9 |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1MGT): | 31-bit |
AMODE (BPX4MGT): | 64-bit |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
|
AMODE 64 callers use BPX4MGT with the same parameters. The Shared_Memory_Size parameter is a doubleword.
Identification for this shared memory segment. This is either a user defined value that serves as a lookup value to determine if the shared memory segment already exists, or the reserved value IPC_PRIVATE. (See BPXYIPCP — Map interprocess communication permissions. IPC_PRIVATE is sometimes used when a process does not want to share a memory segment because it wants to privately control access to it by other processes.)
A fullword (doubleword) field that contains the number of bytes of shared memory that are required. If IPC_MEGA is specified, the value must be a multiple of megabytes, or the request is failed with EINVAL. If IPC_GIGA is specified, the value must be a multiple of gigabytes, or the request is failed with EINVAL. If the caller is running in AMODE 64, the requested number of bytes will be rounded up to the nearest megabyte multiple.
The values that begin with an "IPC_" prefix are defined in BPXYIPCP. They are mapped onto S_TYPE, which is in BPXYMODE. See BPXYIPCP — Map interprocess communication permissions and BPXYMODE — Map the mode constants of the file services.
The values that begin with an "S_I" prefix are defined in BPXYMODE, and are a subset of the access permissions that apply to files.
The name of a fullword in which the shmget service returns the shared memory identifier or, if it is unsuccessful, -1.
Return_code | Explanation |
---|---|
EINVAL | One of the following conditions occurred:
|
EACCES | One of the following conditions occurred:
|
EEXIST | A shared memory identifier exists for the Key parameter, and both IPC_CREAT and IPC_EXCL were specified. The following reason code can accompany the return code: JRIpcExists. |
ENOENT | A shared memory identifier does not exist for the Key parameter, and IPC_CREAT was not specified. The following reason code can accompany the return code: JRIpcNoExists. |
ENOMEM | A shared memory identifier and associated shared memory segment are to be created, but the amount of system storage would exceed the system-imposed limit. The system limit is set with the IPCSHMSPAGES parameter in a BPXPRMxx parmlib member. You can use the ipcs -y shell command to view this value, which is displayed under SPAGES. The following reason code can accompany the return code: JRShmMaxSpages. |
ENOSPC | A shared memory identifier is to be created, but the system-imposed limit on the maximum number of allocated shared memory identifiers system-wide would be exceeded. This system limit is set with the IPCSHMNIDS parameter in a BPXPRMxx parmlib member. You can use the ipcs -x shell command to view this value. You can use the ipcrm shell command to remove unused shared memory identifiers. The following reason code can accompany the return code: JRIpcMaxIDs. |
The name of a fullword in which the shmget service stores the reason code. The shmget service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. See z/OS UNIX System Services Messages and Codes.
For an example using this callable service, see BPX1MGT (shmget) example.