mdoc(7) police: general cleanup.

This commit is contained in:
Ruslan Ermilov 2001-11-21 15:41:49 +00:00
parent 70d2a9e100
commit 5e9a6d9d2b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=86734

View file

@ -38,9 +38,11 @@
.In sys/ipc.h
.In sys/sem.h
.Ft int
.Fn semop "int semid" "struct sembuf array[]" "unsigned nops"
.Fn semop "int semid" "struct sembuf *array" "unsigned nops"
.Sh DESCRIPTION
.Fn Semop
The
.Fn semop
call
atomically performs the array of operations indicated by
.Fa array
on the semaphore set indicated by
@ -50,7 +52,7 @@ The length of
is indicated by
.Fa nops .
Each operation is encoded in a
.Fa "struct sembuf" ,
.Vt "struct sembuf" ,
which is defined as follows:
.Bd -literal
.\"
@ -65,23 +67,24 @@ struct sembuf {
.Pp
For each element in
.Fa array ,
.Fa sem_op
.Va sem_op
and
.Fa sem_flg
.Va sem_flg
determine an operation to be performed on semaphore number
.Fa sem_num
in the set. The values
.Va sem_num
in the set.
The values
.Dv SEM_UNDO
and
.Dv IPC_NOWAIT
may be
.Em OR Ns 'ed
into the
.Fa sem_flg
.Va sem_flg
member in order to modify the behavior of the given operation.
.Pp
The operation performed depends as follows on the value of
.Fa sem_op :
.Va sem_op :
.\"
.\" This section is based on the description of semop() in
.\" Stevens, _Advanced Programming in the UNIX Environment_,
@ -90,38 +93,40 @@ The operation performed depends as follows on the value of
.Bl -bullet
.It
When
.Fa sem_op
.Va sem_op
is positive and the process has alter permission,
the semaphore's value is incremented by
.Fa sem_op Ns 's
value. If
.Va sem_op Ns 's
value.
If
.Dv SEM_UNDO
is specified, the semaphore's adjust on exit value is decremented by
.Fa sem_op Ns 's
value. A positive value for
.Fa sem_op
.Va sem_op Ns 's
value.
A positive value for
.Va sem_op
generally corresponds to a process releasing a resource
associated with the semaphore.
.It
The behavior when
.Fa sem_op
.Va sem_op
is negative and the process has alter permission,
depends on the current value of the semaphore:
.Bl -bullet
.It
If the current value of the semaphore is greater than or equal to
the absolute value of
.Fa sem_op ,
.Va sem_op ,
then the value is decremented by the absolute value of
.Fa sem_op .
.Va sem_op .
If
.Dv SEM_UNDO
is specified, the semaphore's adjust on exit
value is incremented by the absolute value of
.Fa sem_op .
.Va sem_op .
.It
If the current value of the semaphore is less than the absolute value of
.Fa sem_op ,
.Va sem_op ,
one of the following happens:
.\" XXX a *second* sublist?
.Bl -bullet
@ -141,7 +146,7 @@ conditions is satisfied:
Some other process removes the semaphore with the
.Dv IPC_RMID
option of
.Fn semctl .
.Xr semctl 2 .
In this case,
.Fn semop
returns immediately with a return value of
@ -149,29 +154,28 @@ returns immediately with a return value of
.It
The process receives a signal that is to be caught.
In this case, the process will resume execution as defined by
.Fn sigaction .
.Xr sigaction 2 .
.It
The semaphore's
value is greater than or equal to the absolute value of
.Fa sem_op .
.Va sem_op .
When this condition becomes true, the semaphore's value is decremented
by the absolute value of
.Fa sem_op ,
.Va sem_op ,
the semaphore's adjust on exit value is incremented by the
absolute value of
.Fa sem_op .
.Va sem_op .
.El
.El
.El
.Pp
A negative value for
.Fa sem_op
.Va sem_op
generally means that a process is waiting for a resource to become
available.
.El
.Pp
.It
When
.Fa sem_op
.Va sem_op
is zero and the process has read permission,
one of the following will occur:
.Bl -bullet
@ -196,7 +200,7 @@ conditions is satisfied:
Some other process removes the semaphore with the
.Dv IPC_RMID
option of
.Fn semctl .
.Xr semctl 2 .
In this case,
.Fn semop
returns immediately with a return value of
@ -204,29 +208,36 @@ returns immediately with a return value of
.It
The process receives a signal that is to be caught.
In this case, the process will resume execution as defined by
.Fn sigaction
.Xr sigaction 2 .
.It
The semaphore's value becomes zero.
.El
.El
.El
.Pp
For each semaphore a process has in use, the kernel maintains an
`adjust on exit' value, as alluded to earlier. When a process
.Dq "adjust on exit"
value, as alluded to earlier.
When a process
exits, either voluntarily or involuntarily, the adjust on exit value
for each semaphore is added to the semaphore's value. This can
for each semaphore is added to the semaphore's value.
This can
be used to insure that a resource is released if a process terminates
unexpectedly.
.Sh RETURN VALUES
.Rv -std semop
.Sh ERRORS
.Fn Semop
will fail if:
The
.Fn semop
call will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
No semaphore set corresponds to
.Fa semid ,
or the process would exceed the system-defined limit for the number of
per-process SEM_UNDO structures.
per-process
.Dv SEM_UNDO
structures.
.It Bq Er EACCES
Permission denied due to mismatch between operation and mode of
semaphore set.
@ -243,7 +254,7 @@ Too many operations were specified.
.\" I'd have thought this would be EINVAL, but the source says
.\" EFBIG.
.\"
.Fa sem_num
.Va sem_num
was not in the range of valid semaphores for the set.
.It Bq Er EIDRM
The semaphore set was removed from the system.
@ -252,7 +263,9 @@ The
.Fn semop
call was interrupted by a signal.
.It Bq Er ENOSPC
The system SEM_UNDO pool
The system
.Dv SEM_UNDO
pool
.Bq Dv SEMMNU
is full.
.It Bq Er ERANGE
@ -268,7 +281,9 @@ to exceed the system-imposed limits.
.Xr semget 2 ,
.Xr sigaction 2
.Sh BUGS
.Fn Semop
The
.Fn semop
call
may block waiting for memory even if
.Dv IPC_NOWAIT
is specified.
was specified.