Rev | Author | # | Line |
---|---|---|---|
1 | perry | 1 | !!NAME |
2 | semctl - semaphore control operations | ||
3 | !!SYNOPSIS | ||
2 | PerryLorier | 4 | __#include <sys/types.h>__ |
5 | __#include <sys/ipc.h>__ | ||
6 | __#include <sys/sem.h>__ | ||
1 | perry | 7 | |
2 | PerryLorier | 8 | __int semctl(int __''semid''__, int __''semnum''__, int __''cmd''__, ...);__ |
1 | perry | 9 | !!DESCRIPTION |
10 | |||
11 | |||
2 | PerryLorier | 12 | The function performs the control operation specified by ''cmd'' on the semaphore set (or on the ''semnum''-th semaphore of the set) identified by ''semid''. The first |
13 | semaphore of the set is indicated by a value __0__ for ''semnum''. | ||
1 | perry | 14 | |
15 | |||
16 | Legal values for ''cmd'' are | ||
2 | PerryLorier | 17 | ;__IPC_STAT__: Copy info from the semaphore set data structure into the structure pointed to by ''arg''__.buf__. The argument ''semnum'' is ignored. The calling process must have read access privileges on the semaphore set. |
18 | ;__IPC_SET__: Write the values of some members of the __semid_ds__ structure pointed to by ''arg''__.buf__ to the semaphore set data structure, updating also its | ||
19 | __sem_ctime__ member. Considered members from the user supplied __struct semid_ds__ pointed to by ''arg''__.buf__ are | ||
20 | __ sem_perm.uid__ | ||
21 | __sem_perm.gid__ | ||
22 | __sem_perm.mode__ /* only lowest 9-bits */ | ||
23 | ;:The calling process effective user-ID must be one among super-user, creator or owner of the semaphore set. The argument ''semnum'' is ignored. | ||
1 | perry | 24 | |
2 | PerryLorier | 25 | ;__IPC_RMID__: Remove immediately the semaphore set and its data structures awakening all waiting processes (with an error return and __errno__ set to __EIDRM__). The calling process effective user-ID must be one among super-user, creator or owner of the semaphore set. The argument ''semnum'' is ignored. |
1 | perry | 26 | |
2 | PerryLorier | 27 | ;__GETALL__: Return __semval__ for all semaphores of the set into ''arg''__.array__. The argument ''semnum'' is ignored. The calling process must have read access privileges on the semaphore set. |
1 | perry | 28 | |
2 | PerryLorier | 29 | ;__GETNCNT__: The system call returns the value of __semncnt__ for the ''semnum''-th semaphore of the set (i.e. the number of processes waiting for an increase of __semval__ for the ''semnum''-th semaphore of the set). The calling process must have read access privileges on the semaphore set. |
1 | perry | 30 | |
2 | PerryLorier | 31 | ;__GETPID__: The system call returns the value of __sempid__ for the ''semnum''-th semaphore of the set (i.e. the pid of the process that executed the last __semop__ call for the ''semnum''-th semaphore of the set). The calling process must have read access privileges on the semaphore |
1 | perry | 32 | set. |
33 | |||
2 | PerryLorier | 34 | ;__GETVAL__: The system call returns the value of __semval__ for the ''semnum''-th semaphore of the set. The calling process must have read access privileges on the semaphore set. |
1 | perry | 35 | |
2 | PerryLorier | 36 | ;__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. |
1 | perry | 37 | |
2 | PerryLorier | 38 | ;__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 sleeping 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. |
1 | perry | 39 | |
2 | PerryLorier | 40 | ;__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 associated to the set. Undo entry is cleared for altered semaphore in all processes. Processes 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. |
1 | perry | 41 | |
42 | !!RETURN VALUE | ||
2 | PerryLorier | 43 | On fail the system call returns __-1__ with __errno__ indicating the error. Otherwise the system call returns a nonnegative value depending on ''cmd'' as follows: |
1 | perry | 44 | |
2 | PerryLorier | 45 | ;__GETNCNT__: The value of __semncnt__. |
1 | perry | 46 | |
2 | PerryLorier | 47 | ;__GETPID__: the value of __sempid__. |
1 | perry | 48 | |
2 | PerryLorier | 49 | ;__GETVAL__: the value of __semval__. |
1 | perry | 50 | |
2 | PerryLorier | 51 | ;__GETZCNT__: the value of __semzcnt__. |
1 | perry | 52 | |
53 | !!ERRORS | ||
2 | PerryLorier | 54 | For a failing return, __errno__ will be set to one among the following values: |
55 | ;[EACCES]: The calling process has no access permissions needed to execute ''cmd''. | ||
56 | ;[EFAULT]: The address pointed to by ''arg''__.buf__ or ''arg''__.array__ isn't accessible. | ||
57 | ;[EIDRM]: The semaphore set was removed. | ||
58 | ;[EINVAL]: Invalid value for ''cmd'' or ''semid''. | ||
59 | ;[EPERM]: The argument ''cmd'' has value __IPC_SET__ or __IPC_RMID__ but the calling process effective user-ID has insufficient privileges to execute the | ||
1 | perry | 60 | command. |
2 | PerryLorier | 61 | ;[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 |
62 | greater than the implementation value __SEMVMX__. | ||
1 | perry | 63 | !!NOTES |
2 | PerryLorier | 64 | 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 |
65 | these can be modified as needed or moved to a proc file system interface. | ||
1 | perry | 66 | |
2 | PerryLorier | 67 | Various fields in a ''struct semid_ds'' were shorts under Linux 2.2 and have become longs 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 a IPC_64 flag in ''cmd''.) |
1 | perry | 68 | |
2 | PerryLorier | 69 | The following system limit on semaphore sets affects a __semctl__ call: |
1 | perry | 70 | |
2 | PerryLorier | 71 | ;__SEMVMX__: Maximum value for __semval__: implementation dependent (32767). |
1 | perry | 72 | |
73 | !!CONFORMING TO | ||
2 | PerryLorier | 74 | SVr4, SVID. SVr4 documents more error conditions [EINVAL] and [EOVERFLOW]. |
1 | perry | 75 | |
76 | !!SEE ALSO | ||
2 | PerryLorier | 77 | ipc(5), shmget(2), shmat(2), shmdt(2) |
lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 6 times)