Go to the previous, next section.
int semop(int semid, struct sembuf *sops, unsigned
nsops);
semid: [in] the semaphore set on which to perform the operations.
sops: [in] points to an array of operations to perfrom.
nsops: [in] the number of element in sops.
Perform operations on a semaphore set. The sops parameter a
structure sembuf
of the form:
short sem_num
short sem_op;
short sem_flg;
sem_flg may be IPC_NOWAIT
for non blocking calls and
SEM_UNDO
to specify an operation that will be undone on task
termination. The individual operations are perfomed if and only if all
of them will succeed.
The possible values of cmd are:
Whenever a call succeed, the sempid
member of the semaphore set
structure is set to the pid of the current task and the sem_ctime
and sem_otime
member are set to the current time.
On success, the call returns zero. On error -1 is returned and
errno
is set to one of the following values:
E2BIG
: there is too many operations requested (the maximum
is SEMOPM
.
EFBIG
: the semaphore number of some operation is out of range.
EINVAL
: invalid value for semid or nsops.
ERANGE
: semaphore value out of range.
EACCESS
, EAGAIN
, EFAULT
, EIDRM
,
EINTR
or ENOMEM
.
Go to the previous, next section.