Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

semop(2) OSS System Calls Reference Manual
sem_flg Specifies various flags 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 modified semaphore. When the process exits, the
system uses this value to restore the semaphore to the value it
had before any modifications by the process. This flag 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 field 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 field 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_flg & 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 field of the sem structure) is less than the
absolute value of sem_op and (sem_flg & IPC_NOWAIT) is not zero, semop() returns
immediately with an error.
If the semaphores current value (in the semval field of the sem structure) is less than the
absolute value of sem_op and (sem_flg & 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 semaphore’s semncnt value is decremented,
the absolute value of sem_op is subtracted from semval, and, if (sem_flg &
SEM_UNDO) is not zero, the absolute value of sem_op is added to the calling
process’s semadj value for the semaphore.
The semaphore set ID specified 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 field 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_flg & SEM_UNDO) is not zero, the sem_op value is sub-
tracted from the calling processs semadj value for the semaphore.
724 Hewlett-Packard Company 527186-023