The semctl service provides semaphore control operations. These functions include reading and changing the values of semaphores and removing a set of semaphores from the system.
Operation | Environment |
---|---|
Authorization: | Supervisor state or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1SCT): | 31-bit |
AMODE (BPX4SCT): | 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 BPX4SCT with the same parameters. All parameter addresses and addresses in parameter structures are doublewords.
Specifies the semaphore identifier.
Specifies the semaphore number. Semaphore_Number ranges from 0 to Number_of_Semaphores - 1. Use with Sem_GETVAL, Sem_SETVAL, Sem_GETNCNT and Sem_GETZCNT. This argument is ignored for all other commands.
If IPC_BINSEM is specified on the semget call, this option should not be used when there is a possibility that other threads could be performing semaphore operations on this semaphore, as there may be no serialization while the semaphore values are being updated.
Specifies the value to be set for the semaphore that is identified by the Semaphore_Number.
Number | Command | Buffer | Array | Return Value |
---|---|---|---|
Sem No. | GETVAL | NA | SemVal, -1 |
Sem No. | SETVAL | SValue | 0, -1 |
Sem No. | GETPID | NA | Pid, -1 |
Sem No. | GETNCNT | NA | Count, -1 |
Sem No. | GETZCNT | NA | Count, -1 |
NA | GETALL | Array, output | 0, -1 |
NA | SETALL | Array, input | 0, -1 |
NA | STAT | Buffer, output | 0, -1 |
NA | SET | Buffer, input | 0, -1 |
NA | RMID | NA | 0, -1 |
The name of a fullword (doubleword) field that contains the address of a data area that is mapped by SEMID_DS. This field is used for stat and set.
SETALL - A 2-byte integer for each semaphore in the set equal to (SEM_NSEMS * 2).
SETVAL - A 4-byte integer for the specified semaphore. The valid range is 0 through the system limit.
Return_code | Explanation |
---|---|
EACCES | Operation permission (read or alter) is denied to the calling process. The following reason code can accompany the return code: JRIpcDenied. |
EFAULT | The Buffer or ARRAY parameter specified an address that caused the callable service to program check. The following reason code can accompany the return code: JRBadAddress. |
EINVAL | One of the following errors occurred:
|
EPERM | The Command was IPC_RMID or IPC_SET, and the effective user ID of the caller is not that of a process with appropriate privileges (see Authorization) and is not the value of IPC_CUID or IPC_UID in the SEMID_DS data structure that is associated with Semaphore_ID. The following reason code can accompany the return code: JRIpcDenied. |
ERANGE | The SETVAL or SETALL value exceeds the system-imposed maximum that is defined by SEM#MAX_VAL in BPXYSEM. The following reason code can accompany the return code: JRSema4BadValue. |
The name of a fullword in which the semctl service stores the reason code. The semctl 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.
The invoker is restricted by ownership and read and read-write permissions that are defined by semget and semctl Ipc_SET.
For an example using this callable service, see BPX1SCT (semctl) example.