01.01.2013 Views

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SEMOP ( 2) SEMOP {2)<br />

NAME<br />

semop - semaphore operations<br />

SYNOPSIS<br />

#include <br />

#include <br />

#include <br />

int semop (semid, sops, nsops)<br />

int semid;<br />

struct sembuf (*sops)Q;<br />

int nsops;<br />

DESCRIPTION<br />

Semop is used to atomically perform an array of semaphore operations<br />

on the set of semaphores associated with the semaphore<br />

identifier specified by semid . Sops is a pointer to the array of<br />

semaphore-operation structures. Nsops is the number of such<br />

structures in the array. The contents of each structure includes<br />

the following members:<br />

short sem_num; I* semaphore number *I<br />

short sem_op; I* semaphore operation *I<br />

short sem_fig; I* operation flags *I<br />

Each semaphore operation specified by sem_op is performed on<br />

the corresponding semaphore specified by semid and sem_num.<br />

Sem_op specifies one of three semaphore operations as follows:<br />

If sem_op is a negative integer, one of the following will<br />

occur: {ALTER}<br />

If semval (see intro(2)) is greater than or equal to<br />

the absolute value of sem_op, the absolute value<br />

of sem_op is subtracted from semval. Also, if<br />

(sem_ftg & SEM_UNDO) is "true", the absolute<br />

value of sem_op is added to the calling process's<br />

semadj value (see exit(2)) for the specified semaphore.<br />

If semval is Jess than the absolute value of<br />

sem_op and ( sem_ftg & IPC_NOW AIT) is<br />

"true", semop will return immediately.<br />

If semval is Jess than the absolute value of<br />

sem_op and ( sem_ftg & IPC_NOW AIT) is<br />

"false", semop will increment the semncnt associated<br />

with the specified semaphore and suspenf<br />

execution of the calling process until one of th .,<br />

following occurs:<br />

Semval becomes greater than or equal to th.<br />

absolute value of sem_op . When this occur ..<br />

the value of semncnt associated with thf<br />

specified semaphore is decremented, the absolut"<br />

value of sem_op is subtracted from semval an'<br />

if (sem_ftg & SEM_UNDO) is "true", the abs ..<br />

lute value of sem_op is added to the callir_t'<br />

- 1 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!