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

System Functions (s and S) semop(2)
sem_flg Species various ags for the operations. The possible values are as follows:
SEM_UNDO Instructs the system to adjust the processs adjust-on-exit value
(semadj) for a modied semaphore. When the process exits, the
system uses this value to restore the semaphore to the value it
had before any modications by the process. This ag is used to
prevent locking of resources allocated through a semaphore by a
process that no longer exists.
IPC_NOWAIT
Instructs the system to return an error condition if a requested
operation would cause the process to sleep. If the system returns
an error condition, none of the requested semaphore operations
are performed.
If the sem_op eld of the sembuf structure contains a negative integer and the calling process
has alter access permission, the semop() function does one of the following:
If the semaphores current value (in the semval eld of the sem structure) is equal to or
greater than the absolute value of sem_op, the absolute value of sem_op is subtracted
from semval.If(sem_g & SEM_UNDO) is not zero, the absolute value of sem_op is
added to the calling processs semadj value for the semaphore.
If the semaphores current value (in the semval eld of the sem structure) is less than the
absolute value of sem_op and (sem_g & IPC_NOWAIT) is not zero, semop() returns
immediately with an error.
If the semaphores current value (in the semval eld of the sem structure) is less than the
absolute value of sem_op and (sem_g & IPC_NOWAIT) is 0 (zero), semop() incre-
ments the semaphores semncnt value (in the sem structure) and suspends the calling
process. If the process is suspended, it sleeps until one of the following occurs:
The semval value becomes equal to or greater than the absolute value of
sem_op. When this happens, the semaphores semncnt value is decremented,
the absolute value of sem_op is subtracted from semval, and, if (sem_g &
SEM_UNDO) is not zero, the absolute value of sem_op is added to the calling
processs semadj value for the semaphore.
The semaphore set ID specied by the semid parameter is removed from the sys-
tem. When this happens, semop() returns immediately with an error.
The calling process catches a signal. When this happens, the semaphores
semncnt value is decremented and the calling process resumes execution as
directed by the sigaction() function.
If the sem_op eld of the sembuf structure contains a positive integer and the calling process has
alter access permission, semop() adds the sem_op value to the semaphores current semval
value (in the sem structure). If (sem_g & SEM_UNDO) is not zero, the sem_op value is sub-
tracted from the calling processs semadj value for the semaphore.
527186-003 Hewlett-Packard Company 719