semop

Performs a semaphore operation.

Library:LibC
Classification:System-V
Service:Synchronization

Syntax

  #include <sys/sem.h>
   
  int semop (
     int              semid,
     struct sembuf   *sops,
     size_t           nsops );
  

Parameters

semid

(IN) Specifies the semaphore for the operation.

sops

(IN) Points to an array of sembuf structures that describe the semaphore operations.

nsops

(IN) Specifies the number of structures in the sops array.

Return Values

If successful, returns 0; otherwise, returns -1 and sets errno to one of the following values:

Decimal

Constant

Description

2

E2BIG

The nsops parameter is too large.

6

EACCES

The calling thread has insufficient rights to perform the operation.

9

EINVAL

The semid parameter is not a valid semaphore identifier.

12

ENOSPC

Too many undo requests have been received.

14

ERANGE

The operation would cause an overflow of system-imposed limits.

24

EAGAIN

The operation requires waiting but IPC_NOWAIT flag is set.

63

EINTR

A signal interrupted the call.

71

EFBIG

The sembuf.sem_num value is invalid.

105

ENOCONTEXT

The calling thread has no context.

Remarks

The operation must succeeded on all semaphores in the set. If the operation fails on one semaphore, it fails on all semaphores in the set (undoing any actions previously performed).

See Also