he system call returns the value of semval for the semnum-th semaphore of the set. The calling process must have read access privi leges on the semaphore set. GETZCNT The system call returns the value of semzcnt for the semnum-th semaphore of the set (i.e. the number of processes waiting for semval of the semnum-th semaphore of the set to become 0). The calling process must have read access privileges on the semaphore set. SETALL Set semval for all semaphores of the set using arg.array, updating also the sem_ctime member of the semid_ds structure associated to the set. Undo entries are cleared for altered semaphores in all processes. Processes sleep ing on the wait queue are awakened if some semval becomes 0 or increases. The argument semnum is ignored. The calling process must have alter access privileges on the semaphore set. SETVAL Set the value of semval to arg.val for the semnum-th semaphore of the set, updating also the sem_ctime member of the semid_ds structure cesses sleeping on the wait queue are awakened if semval becomes 0 or increases. The calling process must have alter access privileges on the semaphore set.
On fail the system call returns -1 with errno indicating
the error. Otherwise the system call returns a nonnega
tive value depending on cmd as follows:
GETNCNT the value of semncnt.
GETPID the value of sempid.
GETVAL the value of semval.
GETZCNT the value of semzcnt.
For a failing return, errno will be set to one among the
following values:
EACCES The calling process has no access permissions
needed to execute cmd.
EFAULT The address pointed to by arg.buf or arg.array
isn't accessible.
EIDRM The semaphore set was removed.
EINVAL Invalid value for cmd or semid.
EPERM The argument cmd has value IPC_SET or IPC_RMID
but the calling process effective user-ID has
insufficient privileges to execute the command.
ERANGE The argument cmd has value SETALL or SETVAL and
the value to which semval has to be set (for
some semaphore of the set) is less than 0 or
greater than the implementation value SEMVMX.
The IPC_INFO, SEM_STAT and SEM_INFO control calls are used
by the ipcs(8) program to provide information on allocated
resources. In the future these can be modified as needed
or moved to a proc file system interface.
The following system limit on semaphore sets affects a
semctl call:
SEMVMX Maximum value for semval: implementation depen
dent (32767).
SVr4, SVID. SVr4 documents more error conditions EINVAL
and EOVERFLOW.
ipc(5), shmget(2), shmat(2), shmdt(2)
4.4BSD, SVr4, POSIX 1003.1g draft (these function calls
appeared in 4.2BSD).
fcntl(2), recv(2), select(2), getsockopt(2), socket(2),
write(2), socket(4), ip(4), tcp(4), udp(4)