Deleted Added
full compact
locking.9 (233422) locking.9 (233648)
1.\" Copyright (c) 2007 Julian Elischer (julian - freebsd org )
2.\" 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, this list of conditions and the following disclaimer.

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

17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
1.\" Copyright (c) 2007 Julian Elischer (julian - freebsd org )
2.\" 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, this list of conditions and the following disclaimer.

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

17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD: head/share/man/man9/locking.9 233422 2012-03-24 13:37:57Z joel $
25.\" $FreeBSD: head/share/man/man9/locking.9 233648 2012-03-29 05:02:12Z eadler $
26.\"
27.Dd November 3, 2010
28.Dt LOCKING 9
29.Os
30.Sh NAME
31.Nm locking
32.Nd kernel synchronization primitives
33.Sh DESCRIPTION

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

77since they should only read the protected data.
78A thread with exclusive access is known as a
79.Em writer
80since it may modify protected data.
81.Pp
82Reader/writer locks can be treated as mutexes (see above and
83.Xr mutex 9 )
84with shared/exclusive semantics.
26.\"
27.Dd November 3, 2010
28.Dt LOCKING 9
29.Os
30.Sh NAME
31.Nm locking
32.Nd kernel synchronization primitives
33.Sh DESCRIPTION

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

77since they should only read the protected data.
78A thread with exclusive access is known as a
79.Em writer
80since it may modify protected data.
81.Pp
82Reader/writer locks can be treated as mutexes (see above and
83.Xr mutex 9 )
84with shared/exclusive semantics.
85More specifically, regular mutexes can be
85More specifically, regular mutexes can be
86considered to be equivalent to a write-lock on an
87.Em rw_lock.
88The
89.Em rw_lock
90locks have priority propagation like mutexes, but priority
91can be propagated only to an exclusive holder.
92This limitation comes from the fact that shared owners
93are anonymous.
94Another important property is that shared holders of
95.Em rw_lock
96can recurse, but exclusive locks are not allowed to recurse.
86considered to be equivalent to a write-lock on an
87.Em rw_lock.
88The
89.Em rw_lock
90locks have priority propagation like mutexes, but priority
91can be propagated only to an exclusive holder.
92This limitation comes from the fact that shared owners
93are anonymous.
94Another important property is that shared holders of
95.Em rw_lock
96can recurse, but exclusive locks are not allowed to recurse.
97This ability should not be used lightly and
97This ability should not be used lightly and
98.Em may go away.
99.Pp
100See
101.Xr rwlock 9
102for details.
103.Ss Read-mostly locks
104Mostly reader locks are similar to
105.Em reader/writer

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

117Shared/exclusive locks are similar to reader/writer locks; the main difference
118between them is that shared/exclusive locks may be held during unbounded sleep
119(and may thus perform an unbounded sleep).
120They are inherently less efficient than mutexes, reader/writer locks
121and read-mostly locks.
122They don't support priority propagation.
123They should be considered to be closely related to
124.Xr sleep 9 .
98.Em may go away.
99.Pp
100See
101.Xr rwlock 9
102for details.
103.Ss Read-mostly locks
104Mostly reader locks are similar to
105.Em reader/writer

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

117Shared/exclusive locks are similar to reader/writer locks; the main difference
118between them is that shared/exclusive locks may be held during unbounded sleep
119(and may thus perform an unbounded sleep).
120They are inherently less efficient than mutexes, reader/writer locks
121and read-mostly locks.
122They don't support priority propagation.
123They should be considered to be closely related to
124.Xr sleep 9 .
125In fact it could in some cases be
125In fact it could in some cases be
126considered a conditional sleep.
127.Pp
128See
129.Xr sx 9
130for details.
131.Ss Counting semaphores
132Counting semaphores provide a mechanism for synchronizing access
133to a pool of resources.

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

334for details.
335.Ss Context mode table
336The next table shows what can be used in different contexts.
337At this time this is a rather easy to remember table.
338.Bl -column ".Ic Xxxxxxxxxxxxxxxxxxx" ".Xr XXXXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXX" -offset indent
339.It Xo
340.Em "Context:" Ta spin mtx Ta mutex Ta sx Ta rwlock Ta rmlock Ta sleep
341.Xc
126considered a conditional sleep.
127.Pp
128See
129.Xr sx 9
130for details.
131.Ss Counting semaphores
132Counting semaphores provide a mechanism for synchronizing access
133to a pool of resources.

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

334for details.
335.Ss Context mode table
336The next table shows what can be used in different contexts.
337At this time this is a rather easy to remember table.
338.Bl -column ".Ic Xxxxxxxxxxxxxxxxxxx" ".Xr XXXXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXXX" ".Xr XXXXXX" -offset indent
339.It Xo
340.Em "Context:" Ta spin mtx Ta mutex Ta sx Ta rwlock Ta rmlock Ta sleep
341.Xc
342.It interrupt filter: Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no
343.It interrupt thread: Ta \&ok Ta \&ok Ta \&no Ta \&ok Ta \&ok Ta \&no
344.It callout: Ta \&ok Ta \&ok Ta \&no Ta \&ok Ta \&no Ta \&no
345.It syscall: Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok
342.It interrupt filter: Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no
343.It interrupt thread: Ta \&ok Ta \&ok Ta \&no Ta \&ok Ta \&ok Ta \&no
344.It callout: Ta \&ok Ta \&ok Ta \&no Ta \&ok Ta \&no Ta \&no
345.It syscall: Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok
346.El
347.Sh SEE ALSO
348.Xr witness 4 ,
349.Xr condvar 9 ,
350.Xr lock 9 ,
351.Xr mtx_pool 9 ,
352.Xr mutex 9 ,
353.Xr rmlock 9 ,

--- 14 unchanged lines hidden ---
346.El
347.Sh SEE ALSO
348.Xr witness 4 ,
349.Xr condvar 9 ,
350.Xr lock 9 ,
351.Xr mtx_pool 9 ,
352.Xr mutex 9 ,
353.Xr rmlock 9 ,

--- 14 unchanged lines hidden ---