Document that sx_unlock() exists as a macro.

Remove redundant include file, <sys/kernel.h>, and clean up the function
list at the top with the addition of a "Sx utility macro" section.
This commit is contained in:
darrenr 2004-07-11 16:08:25 +00:00
parent 210d568a00
commit 6c66c4291a

View File

@ -42,6 +42,7 @@
.Nm sx_try_upgrade , .Nm sx_try_upgrade ,
.Nm sx_downgrade , .Nm sx_downgrade ,
.Nm sx_assert , .Nm sx_assert ,
.Nm sx_unlock ,
.Nm SX_SYSINIT .Nm SX_SYSINIT
.Nd kernel shared/exclusive lock .Nd kernel shared/exclusive lock
.Sh SYNOPSIS .Sh SYNOPSIS
@ -68,13 +69,16 @@
.Fn sx_try_upgrade "struct sx *sx" .Fn sx_try_upgrade "struct sx *sx"
.Ft void .Ft void
.Fn sx_downgrade "struct sx *sx" .Fn sx_downgrade "struct sx *sx"
.Pp
.Cd "options INVARIANTS"
.Cd "options INVARIANT_SUPPORT"
.Ft void .Ft void
.Fn sx_assert "struct sx *sx" "int what" .Fn sx_assert "struct sx *sx" "int what"
.In sys/kernel.h .\"
.Ss sx utility macros
.Fn sx_unlock "struct sx *sx"
.Fn SX_SYSINIT "name" "struct sx *sx" "const char *description" .Fn SX_SYSINIT "name" "struct sx *sx" "const char *description"
.\"
.Ss Kernel options
.Cd "options INVARIANTS"
.Cd "options INVARIANT_SUPPORT"
.Sh DESCRIPTION .Sh DESCRIPTION
Shared/exclusive locks are used to protect data that are read far more often Shared/exclusive locks are used to protect data that are read far more often
than they are written. than they are written.
@ -98,13 +102,17 @@ Threads acquire and release a shared lock by calling
or or
.Fn sx_try_slock .Fn sx_try_slock
and and
.Fn sx_sunlock . .Fn sx_sunlock
or
.Fn sx_unlock .
Threads acquire and release an exclusive lock by calling Threads acquire and release an exclusive lock by calling
.Fn sx_xlock .Fn sx_xlock
or or
.Fn sx_try_xlock .Fn sx_try_xlock
and and
.Fn sx_xunlock . .Fn sx_xunlock
or
.Fn sx_unlock .
A thread can attempt to upgrade a currently held shared lock to an exclusive A thread can attempt to upgrade a currently held shared lock to an exclusive
lock by calling lock by calling
.Fn sx_try_upgrade . .Fn sx_try_upgrade .
@ -158,6 +166,15 @@ lock pointed to
by the first argument. by the first argument.
.El .El
.Pp .Pp
For ease of programming,
.Fn sx_unlock
is provided as a macro frontend to the respective functions,
.Fn sx_sunlock
and
.Fn sx_xunlock .
Algorithms that are aware of what state the lock is in should use either
of the two specific functions for a minor performance benefit.
.Pp
The The
.Fn SX_SYSINIT .Fn SX_SYSINIT
macro is used to generate a call to the macro is used to generate a call to the