aboutsummaryrefslogtreecommitdiff
path: root/share/man/man9/sx.9
diff options
context:
space:
mode:
authorJason Evans <jasone@FreeBSD.org>2001-08-13 21:25:30 +0000
committerJason Evans <jasone@FreeBSD.org>2001-08-13 21:25:30 +0000
commitd55229b72ecc97075f1afcd976f8e0c1cd0d662b (patch)
tree67194a60468f548a491adff90351cbea4c362c47 /share/man/man9/sx.9
parent9c347fa6263ae87ab59c560c9a8c6b362001000e (diff)
downloadsrc-d55229b72ecc97075f1afcd976f8e0c1cd0d662b.tar.gz
src-d55229b72ecc97075f1afcd976f8e0c1cd0d662b.zip
Add sx_try_upgrade() and sx_downgrade().
Submitted by: Alexander Kabaev <ak03@gte.com>
Notes
Notes: svn path=/head/; revision=81599
Diffstat (limited to 'share/man/man9/sx.9')
-rw-r--r--share/man/man9/sx.917
1 files changed, 17 insertions, 0 deletions
diff --git a/share/man/man9/sx.9 b/share/man/man9/sx.9
index 2fa030224838..945098946271 100644
--- a/share/man/man9/sx.9
+++ b/share/man/man9/sx.9
@@ -39,6 +39,8 @@
.Nm sx_try_xlock ,
.Nm sx_sunlock ,
.Nm sx_xunlock
+.Nm sx_try_upgrade
+.Nm sx_downgrade
.Nd kernel shared/exclusive lock
.Sh SYNOPSIS
.Fd #include <sys/types.h>
@@ -61,6 +63,10 @@
.Fn sx_sunlock "struct sx *sx"
.Ft void
.Fn sx_xunlock "struct sx *sx"
+.Ft int
+.Fn sx_try_upgrade "struct sx *sx"
+.Ft void
+.Fn sx_downgrade "struct sx *sx"
.Sh DESCRIPTION
Shared/exclusive locks are used to protect data that are read far more often
than they are written.
@@ -91,6 +97,12 @@ or
.Fn sx_try_xlock
and
.Fn sx_xunlock .
+A thread can attempt to upgrade a currently owned shared lock to an exclusive
+lock by calling
+.Fn sx_try_upgrade .
+A thread that owns an exclusive lock can downgrade it to a shared lock by
+calling
+.Fn sx_downgrade .
.Pp
.Fn sx_try_slock
and
@@ -99,6 +111,11 @@ 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
+.Fn sx_try_upgrade
+will return 0 if the shared lock cannot be upgraded to an exclusive lock
+immediately; otherwise the 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