The semget function creates a new semaphore set or finds an existing semaphore set. The semaphore set ID is returned.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1SGT): | 31-bit |
AMODE (BPX4SGT): | 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 BPX4SGT with the same parameters.
Identification for this semaphore set. This is either a user-defined value that serves as a lookup value to determine if the semaphore set 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 semaphore set, or when it wants to privately control access to it by other processes.)
The number of semaphores that are to be allocated to this set. This value may be zero if the application knows that the semaphore set should already be created for the specified key parameter. A zero value is not allowed with Ipc_CREAT or Ipc_PRIVATE. The maximum for this variable is controlled by the installation. For an existing semaphore identifier, this variable must not be greater than the number of semaphores in that set.
The values that begin with the "Ipc_" prefix are defined in BPXYIPCP and 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 the "S_I" prefix are defined in BPXYMODE, and are a subset of the access permissions that apply to files.
This operand is ignored if the semaphore set is already defined to the system.
The name of a fullword in which the semget service returns the semaphore identifier or, if unsuccessful, -1.
Return_code | Explanation |
---|---|
EACCES | A semaphore identifier exists for the Key parameter, but access permission, as specified by the low-order 9 bits of the Semaphore_Flags parameter, is not granted (the "S_" items). The following reason code can accompany the return code: JRIpcDenied. |
EEXIST | A semaphore identifier exists for the Key parameter, and both Ipc_CREAT and Ipc_EXCL are specified. The following reason code can accompany the return code: JRIpcExists. |
EINVAL | Number_of_Semaphores is not valid when:
The Semaphore_Flags parameter includes bits that are not supported by this function. The following reason codes can accompany the return code: JRSema4BadNSems, JRSema4ZeroNSems, JRSema4BigNSems, and JRIpcBadFlags. |
ENOENT | A semaphore identifier does not exist for the Key parameter and Ipc_CREAT was not set. The following reason code can accompany the return code: JRIpcNoExists. |
ENOSPC | A semaphore identifier is to be created, but the system-imposed limit on the maximum number of allocated semaphore identifiers system-wide would be exceeded. This system limit is set with the IPCSEMNIDS parameter in the BPXPRM parmlib member. You can use ipcs -x shell command to the view this value. You can use the ipcrm shell command to remove unused semaphore identifiers. The following reason code can accompany the return code: JRIpcMaxIDs. |
The name of a fullword in which the semget service stores the reason code. The semget 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 the reason codes.
For the data structure, see BPXYSEM — Map interprocess communication semaphores.
For an example using this callable service, see BPX1SGT (semget) example.