semctl.2

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 214 行

2
214
字号
.\" SCCSID: @(#)semctl.2	8.1	9/11/90.TH semctl 2.SH Namesemctl \- semaphore control operations.SH Syntax.nf.B #include <sys/types.h\fP>.B #include <sys/ipc.h\fP>.B #include <sys/sem.h\fP>.PP.B int semctl (\fIsemid, semnum, cmd, arg\fP).B int \fIsemid, cmd\fP;.B int \fIsemnum\fP;.B union \fIsemun\fP {	\fIint val\fP;	\fIstruct semid_ds *buf\fP;	\fIushort array[]\fP;} arg\fP;.fi.in \-8.SH Description.NXR "semctl system call".NXR "semaphore" "control operations".NXR "semctl system call" "semget system call".NXR "semctl system call" "semop system call"The.PN semctlsystem callprovides a variety of semaphore control operations as specified by .IR cmd .The following .IR cmd sare executed with respect to the semaphore specified by.I semidand.IR semnum :.TP 15GETVALReturn the value of .IR semval .For further information, see.MS intro 2 ..TP 15SETVALSet the value of .I semvalto arg.val.  When this command is successfullyexecuted, the .I semadjvalue correspondingto the specified semaphore in allprocesses is cleared..TP 15GETPIDReturn the value of.IR sempid ..TP 15GETNCNTReturn the value of .IR semncnt . .TP 15GETZCNTReturn the value of.IR semzcnt . .PPThe following.IR cmd sreturn and set every .I semvalin the set of semaphores:.NXR "semctl system call" "commands".TP 15GETALLPlace .IR semval s into array pointed to by.IR arg.array ..TP 15SETALLSet .IR semval s according to the array pointed to by.I arg.arrayWhen this command is successfully executed,the .I semadjvalues correspondingto each specified semaphore in all processes are cleared..PPThe following .IR cmd sare also available:.TP 15IPC_STATPlace the current value of each member of the data structure associated with .I semid into the  structure pointed to by.IR arg.buf .The contents of this structure are defined in .MS intro 2 ..TP 15IPC_SETSet the value of the following members of the data structure associated with.I semid to the corresponding value found in the structure pointed to by.IR arg.buf :.EXsem_perm.uidsem_perm.gidsem_perm.mode /* only low 9 bits */.EE.PPThis command can only be executed by a process that has an effective user ID equal to superuser or to the values of.B sem_perm.uidor.B sem_perm.cuidin the data structure associated with.IR semid ..TP 15IPC_RMIDRemove the semaphore identifier specified by .I semidfrom the system and destroy the setof semaphores and data structure associatedwith it.This .I cmd can only be executed by a process that has an effective userID equal to either that of superuser or to the value of.B sem_perm.uidin the data structure associated with.IR semid ..SH Return ValuesUpon successful completion, the value returned depends on .IR cmd ,as follows:.TP 15GETVALThe value of.IR semval ..TP 15GETPIDThe value of.IR sempid ..TP 15GETNCNTThe value of .IR semncnt ..TP 15GETZCNTThe value of .IR semzcnt ..TP 15All otherA value of 0..RE.PPOtherwise, a value of \-1 is returned and.I errnois set to indicate the error..SH Diagnostics.NXR "semctl system call" "diagnostics"The.PN semctlsystem call fails if any of the following is true:.TP 15[EINVAL]The.I semidis not a valid semaphore identifier. .TP 15[EINVAL]The.I semnumis less than zero or greater than.B sem_nsems..TP 15[EINVAL]The.I cmdis not a valid command. .TP 15[EACCES]Operation permission is denied to the calling process.For further information, see .MS errno 2 . .TP 15[ERANGE]The.I cmdis SETVAL or SETALL,and the value to which semval is to be setis greater than the system imposed maximum. .TP 15[EPERM]The.I cmdis equal to IPC_RMIDor IPC_SET and the effective user ID of the callingprocess is not equal to that of superusernor to the value of.B sem_perm.uidin the data structure associated with.IR semid ..TP 15[EFAULT]The.I arg.bufpoints to an illegal address. .SH See Alsoerrno(2), intro(2), semget(2), semop(2)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?