операции управления семафором System V (System V semaphore control operations)
Примечание (Note)
The IPC_INFO
, SEM_STAT
, and SEM_INFO
operations are used by the
ipcs(1) program to provide information on allocated resources.
In the future these may modified or moved to a /proc filesystem
interface.
Various fields in a struct semid_ds were typed as short under
Linux 2.2 and have become long under Linux 2.4. To take
advantage of this, a recompilation under glibc-2.1.91 or later
should suffice. (The kernel distinguishes old and new calls by
an IPC_64
flag in cmd.)
In some earlier versions of glibc, the semun union was defined in
<sys/sem.h>, but POSIX.1 requires that the caller define this
union. On versions of glibc where this union is not defined, the
macro _SEM_SEMUN_UNDEFINED
is defined in <sys/sem.h>.
The following system limit on semaphore sets affects a semctl
()
call:
SEMVMX
Maximum value for semval
: implementation dependent
(32767).
For greater portability, it is best to always call semctl
() with
four arguments.
The sempid value
POSIX.1 defines sempid as the "process ID of [the] last
operation" on a semaphore, and explicitly notes that this value
is set by a successful semop(2) call, with the implication that
no other interface affects the sempid value.
While some implementations conform to the behavior specified in
POSIX.1, others do not. (The fault here probably lies with
POSIX.1 inasmuch as it likely failed to capture the full range of
existing implementation behaviors.) Various other
implementations also update sempid for the other operations that
update the value of a semaphore: the SETVAL
and SETALL
operations, as well as the semaphore adjustments performed on
process termination as a consequence of the use of the SEM_UNDO
flag (see semop(2)).
Linux also updates sempid for SETVAL
operations and semaphore
adjustments. However, somewhat inconsistently, up to and
including Linux 4.5, the kernel did not update sempid for SETALL
operations. This was rectified in Linux 4.6.