Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (s and S) semop(2)
NAME
semop - Performs semaphore operations
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossksrl
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zosskdll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/yosskdll
SYNOPSIS
#include <sys/sem.h>
int semop(
int semid,
struct sembuf *sops,
size_t nsops);
PARAMETERS
semid Specifies the ID of the semaphore set.
sops Points to the user-defined array of sembuf structures that contain the semaphore
operations.
nsops Specifies the number of sembuf structures in the array.
DESCRIPTION
The semop() function atomically performs a set of operations on the semaphores specified by the
sem_num fields in the structures pointed to by the sops parameter and by the semaphore set ID
specified as the semid parameter.
If a process cannot execute a specified operation on a single semaphore within the specified
semaphore set, it cannot execute any operation on any semaphore within that set. Values related
to any semaphores in the set remain unchanged by the failed call to the semop() function. (The
calling process’s adjust-on-exit value, semadj, for the semaphore is also unaffected by a failed
call. Refer to the exit(3) reference page for more information about semadj use.)
All processes waiting (suspended) for a semaphore are awakened when an operation occurs that
could cause any one of them to proceed.
The semaphore operations are defined in the array pointed to by the sops parameter. The sops
array contains nsops elements, each of which is represented by a sembuf structure.
The sembuf structure (from the sys/sem.h header file) is defined as follows:
struct sembuf {
unsigned short int sem_num;
short int sem_op;
short int sem_flg;
};
The fields in the sembuf structure are defined as follows:
sem_num Specifies an individual semaphore within the semaphore set.
sem_op Specifies the operation to perform on the semaphore. The sem_op operation is
specified as a negative integer, a positive integer, or 0 (zero). The effects of
these operations are described later in this reference page.
527186-023 Hewlett-Packard Company 7−23