From 920ae52d678bc16521b7a6d39f2c1070910d9701 Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Tue, 7 Aug 2001 04:29:53 +0000 Subject: [PATCH] Document sx_try_[sx]lock(). --- share/man/man9/Makefile | 2 ++ share/man/man9/sx.9 | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index dd5f3d8684df..53195bbcc106 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -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 diff --git a/share/man/man9/sx.9 b/share/man/man9/sx.9 index 5fa5dd3b98cc..acb088052479 100644 --- a/share/man/man9/sx.9 +++ b/share/man/man9/sx.9 @@ -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