Deleted Added
full compact
sx.9 (167371) sx.9 (167387)
1.\"
2.\" Copyright (C) 2001 Jason Evans <jasone@FreeBSD.org>. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice(s), this list of conditions and the following disclaimer as

--- 10 unchanged lines hidden (view full) ---

19.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25.\" DAMAGE.
26.\"
1.\"
2.\" Copyright (C) 2001 Jason Evans <jasone@FreeBSD.org>. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice(s), this list of conditions and the following disclaimer as

--- 10 unchanged lines hidden (view full) ---

19.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
25.\" DAMAGE.
26.\"
27.\" $FreeBSD: head/share/man/man9/sx.9 167371 2007-03-09 16:52:26Z jhb $
27.\" $FreeBSD: head/share/man/man9/sx.9 167387 2007-03-09 22:41:01Z jhb $
28.\"
29.Dd February 1, 2006
30.Dt SX 9
31.Os
32.Sh NAME
33.Nm sx ,
34.Nm sx_init ,
35.Nm sx_destroy ,
36.Nm sx_slock ,
37.Nm sx_xlock ,
38.Nm sx_try_slock ,
39.Nm sx_try_xlock ,
40.Nm sx_sunlock ,
41.Nm sx_xunlock ,
42.Nm sx_unlock ,
43.Nm sx_try_upgrade ,
44.Nm sx_downgrade ,
28.\"
29.Dd February 1, 2006
30.Dt SX 9
31.Os
32.Sh NAME
33.Nm sx ,
34.Nm sx_init ,
35.Nm sx_destroy ,
36.Nm sx_slock ,
37.Nm sx_xlock ,
38.Nm sx_try_slock ,
39.Nm sx_try_xlock ,
40.Nm sx_sunlock ,
41.Nm sx_xunlock ,
42.Nm sx_unlock ,
43.Nm sx_try_upgrade ,
44.Nm sx_downgrade ,
45.Nm sx_sleep ,
45.Nm sx_xlocked ,
46.Nm sx_assert ,
47.Nm SX_SYSINIT
48.Nd kernel shared/exclusive lock
49.Sh SYNOPSIS
50.In sys/param.h
51.In sys/lock.h
52.In sys/sx.h

--- 15 unchanged lines hidden (view full) ---

68.Fn sx_xunlock "struct sx *sx"
69.Ft void
70.Fn sx_unlock "struct sx *sx"
71.Ft int
72.Fn sx_try_upgrade "struct sx *sx"
73.Ft void
74.Fn sx_downgrade "struct sx *sx"
75.Ft int
46.Nm sx_xlocked ,
47.Nm sx_assert ,
48.Nm SX_SYSINIT
49.Nd kernel shared/exclusive lock
50.Sh SYNOPSIS
51.In sys/param.h
52.In sys/lock.h
53.In sys/sx.h

--- 15 unchanged lines hidden (view full) ---

69.Fn sx_xunlock "struct sx *sx"
70.Ft void
71.Fn sx_unlock "struct sx *sx"
72.Ft int
73.Fn sx_try_upgrade "struct sx *sx"
74.Ft void
75.Fn sx_downgrade "struct sx *sx"
76.Ft int
77.Fn sx_sleep "void *chan" "struct sx *sx" "int priority" "const char *wmesg" "int timo"
78.Ft int
76.Fn sx_xlocked "struct sx *sx"
77.Pp
78.Cd "options INVARIANTS"
79.Cd "options INVARIANT_SUPPORT"
80.Ft void
81.Fn sx_assert "struct sx *sx" "int what"
82.In sys/kernel.h
83.Fn SX_SYSINIT "name" "struct sx *sx" "const char *description"

--- 45 unchanged lines hidden (view full) ---

129otherwise the shared/exclusive lock will be acquired and a non-zero value will
130be returned.
131.Pp
132.Fn sx_try_upgrade
133will return 0 if the shared lock cannot be upgraded to an exclusive lock
134immediately; otherwise the exclusive lock will be acquired and a non-zero value
135will be returned.
136.Pp
79.Fn sx_xlocked "struct sx *sx"
80.Pp
81.Cd "options INVARIANTS"
82.Cd "options INVARIANT_SUPPORT"
83.Ft void
84.Fn sx_assert "struct sx *sx" "int what"
85.In sys/kernel.h
86.Fn SX_SYSINIT "name" "struct sx *sx" "const char *description"

--- 45 unchanged lines hidden (view full) ---

132otherwise the shared/exclusive lock will be acquired and a non-zero value will
133be returned.
134.Pp
135.Fn sx_try_upgrade
136will return 0 if the shared lock cannot be upgraded to an exclusive lock
137immediately; otherwise the exclusive lock will be acquired and a non-zero value
138will be returned.
139.Pp
140A thread can atomically release a shared/exclusive lock while waiting for an
141event by calling
142.Fn sx_sleep .
143For more details on the parameters to this function,
144see
145.Xr sleep 9 .
146.Pp
137When compiled with
138.Cd "options INVARIANTS"
139and
140.Cd "options INVARIANT_SUPPORT" ,
141the
142.Fn sx_assert
143function tests
144.Fa sx

--- 19 unchanged lines hidden (view full) ---

164.It Dv SX_UNLOCKED
165Assert that the current thread has no lock on the
166.Vt sx
167lock pointed to
168by the first argument.
169.El
170.Pp
171.Fn sx_xlocked
147When compiled with
148.Cd "options INVARIANTS"
149and
150.Cd "options INVARIANT_SUPPORT" ,
151the
152.Fn sx_assert
153function tests
154.Fa sx

--- 19 unchanged lines hidden (view full) ---

174.It Dv SX_UNLOCKED
175Assert that the current thread has no lock on the
176.Vt sx
177lock pointed to
178by the first argument.
179.El
180.Pp
181.Fn sx_xlocked
172will return non-zero if the current process holds the exclusive lock;
182will return non-zero if the current thread holds the exclusive lock;
173otherwise, it will return zero.
174.Pp
175For ease of programming,
176.Fn sx_unlock
177is provided as a macro frontend to the respective functions,
178.Fn sx_sunlock
179and
180.Fn sx_xunlock .

--- 52 unchanged lines hidden ---
183otherwise, it will return zero.
184.Pp
185For ease of programming,
186.Fn sx_unlock
187is provided as a macro frontend to the respective functions,
188.Fn sx_sunlock
189and
190.Fn sx_xunlock .

--- 52 unchanged lines hidden ---