Copyright (C) 2000-2012 |
GNU Info (ipc.info)semctlsemctl ------ int semctl (int semid, int semnum, int cmd, union semun arg); * semid : id obtained by a call to semget. * cmd : GETPID return pid for the process that executed the last semop. GETVAL return semval of semaphore with index semnum. GETNCNT return number of processes waiting for semval to increase. GETZCNT return number of processes waiting for semval to become 0 SETVAL set semval = arg.val. GETALL read all semval's into arg.array. SETALL set all semval's with values given in arg.array. * returns : 0 on success or as given above. -1 on failure. The first 4 operate on the semaphore with index semnum in the set. The last two operate on all semaphores in the set. `arg' is a union : union semun int val; value for SETVAL. struct semid_ds *buf; buffer for IPC_STAT and IPC_SET. ushort *array; array for GETALL and SETALL * IPC_SET, SETVAL, SETALL : sem_ctime is updated. * SETVAL, SETALL : Undo entries are cleared for altered semaphores in all processes. Processes sleeping on the wait queues are awakened if a semval becomes 0 or increases. * IPC_SET : sem_perm.uid, sem_perm.gid, sem_perm.mode are updated from user supplied values. Errors: EACCES : do not have permission for specified access. EFAULT : arg is not accessible. EIDRM : The resource was removed. EINVAL : semid < 0 or semnum < 0 or semnum >= nsems. EPERM : IPC_RMID, IPC_SET ... not creator, owner or super-user. ERANGE : arg.array[i].semval > SEMVMX or < 0 for some i. automatically generated by info2www version 1.2.2.9 |