Document sx_try_[sx]lock().

This commit is contained in:
Jason Evans 2001-08-07 04:29:53 +00:00
parent b5b9b43078
commit 920ae52d67
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81223
2 changed files with 19 additions and 0 deletions

View file

@ -164,6 +164,8 @@ MLINKS+=sx.9 sx_init.9
MLINKS+=sx.9 sx_destroy.9
MLINKS+=sx.9 sx_slock.9
MLINKS+=sx.9 sx_xlock.9
MLINKS+=sx.9 sx_try_slock.9
MLINKS+=sx.9 sx_try_xlock.9
MLINKS+=sx.9 sx_sunlock.9
MLINKS+=sx.9 sx_xunlock.9
MLINKS+=time.9 boottime.9 time.9 mono_time.9 time.9 runtime.9

View file

@ -35,6 +35,8 @@
.Nm sx_destroy ,
.Nm sx_slock ,
.Nm sx_xlock ,
.Nm sx_try_slock ,
.Nm sx_try_xlock ,
.Nm sx_sunlock ,
.Nm sx_xunlock
.Nd kernel shared/exclusive lock
@ -51,6 +53,10 @@
.Fn sx_slock "struct sx *sx"
.Ft void
.Fn sx_xlock "struct sx *sx"
.Ft int
.Fn sx_try_slock "struct sx *sx"
.Ft int
.Fn sx_try_xlock "struct sx *sx"
.Ft void
.Fn sx_sunlock "struct sx *sx"
.Ft void
@ -75,13 +81,24 @@ Shared/exclusive locks are destroyed with
.Fn sx_destroy .
Threads acquire and release a shared lock by calling
.Fn sx_slock
or
.Fn sx_try_slock
and
.Fn sx_sunlock .
Threads acquire and release an exclusive lock by calling
.Fn sx_xlock
or
.Fn sx_try_xlock
and
.Fn sx_xunlock .
.Pp
.Fn sx_try_slock
and
.Fn sx_try_xlock
will return 0 if the shared/exclusive lock cannot be acquired immediately;
otherwise the shared/exclusive lock will be acquired and a non-zero value will
be returned.
.Pp
A thread may not own a shared lock and an exclusive lock simultaneously;
attempting to do so will result in deadlock.
.Sh SEE ALSO