Semop: When decreasing a set of semaphores are all decremented at once or does it block on first failure?
No updates happen until all updates can proceed as a unit.
The POSIX specification could be clearer about this point, although it does say that semop
is atomic.
On Linux, semop(3)
in glibc is a simple wrapper around semop(2)
. The semop(2)
manpage in turn says
The set of operations contained in
sops
is performed in array order, and atomically, that is, the operations are performed either as a complete unit, or not at all.
The HP-UX semop(2)
manpage is even clearer:
Semaphore array operations are atomic in that none of the semaphore operations are performed until blocking conditions on all of the semaphores in the array have been removed.