Open System Services System Calls Reference Manual (G06.25+, H06.03+)

semop(2) OSS System Calls Reference Manual
NAME
semop - Performs semaphore operations
LIBRARY
G-series native OSS processes: /G/system/sysnn/zossksrl
H-series OSS processes: /G/system/zdllnnn/zosskdll
SYNOPSIS
#include <sys/sem.h>
int semop(
int semid,
struct sembuf *sops,
size_t nsops);
PARAMETERS
semid Species the ID of the semaphore set.
sops Points to the user-dened array of sembuf structures that contain the semaphore
operations.
nsops Species the number of sembuf structures in the array.
DESCRIPTION
The semop() function atomically performs a set of operations on the semaphores specied by the
sem_num elds in the structures pointed to by the sops parameter and by the semaphore set ID
specied as the semid parameter.
If a process cannot execute a specied operation on a single semaphore within the specied
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 processs 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 dened 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 le) is dened as follows:
struct sembuf {
unsigned short int sem_num;
short int sem_op;
short int sem_flg;
};
The elds in the sembuf structure are dened as follows:
sem_num Species an individual semaphore within the semaphore set.
sem_op Species the operation to perform on the semaphore. The sem_op operation is
specied as a negative integer, a positive integer, or 0 (zero). The effects of
these operations are described later in this reference page.
718 Hewlett-Packard Company 527186-003