Deleted Added
full compact
rmlock.9 (227588) rmlock.9 (233648)
1.\" Copyright (c) 2007 Stephan Uphoff <ups@FreeBSD.org>
2.\" Copyright (c) 2006 Gleb Smirnoff <glebius@FreeBSD.org>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright

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

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

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

18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD: head/share/man/man9/rmlock.9 227588 2011-11-16 21:51:17Z pjd $
26.\" $FreeBSD: head/share/man/man9/rmlock.9 233648 2012-03-29 05:02:12Z eadler $
27.\"
28.\" Based on rwlock.9 man page
29.Dd November 16, 2011
30.Dt RMLOCK 9
31.Os
32.Sh NAME
33.Nm rmlock ,
34.Nm rm_init ,

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

75A thread with exclusive access is known as a
76.Em writer
77since it can modify protected data.
78.Pp
79Read mostly locks are designed to be efficient for locks almost exclusively
80used as reader locks and as such should be used for protecting data that
81rarely changes.
82Acquiring an exclusive lock after the lock had been locked for shared access
27.\"
28.\" Based on rwlock.9 man page
29.Dd November 16, 2011
30.Dt RMLOCK 9
31.Os
32.Sh NAME
33.Nm rmlock ,
34.Nm rm_init ,

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

75A thread with exclusive access is known as a
76.Em writer
77since it can modify protected data.
78.Pp
79Read mostly locks are designed to be efficient for locks almost exclusively
80used as reader locks and as such should be used for protecting data that
81rarely changes.
82Acquiring an exclusive lock after the lock had been locked for shared access
83is an expensive operation.
83is an expensive operation.
84.Pp
85Although reader/writer locks look very similar to
86.Xr sx 9
87locks, their usage pattern is different.
88Reader/writer locks can be treated as mutexes (see
89.Xr mutex 9 )
90with shared/exclusive semantics unless initialized with
91.Dv RM_SLEEPABLE .

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

191The
192.Fn rm_wlock
193function cannot be called recursively.
194.It Fn rm_runlock "struct rmlock *rm" "struct rm_priotracker* tracker"
195This function releases a shared lock previously acquired by
196.Fn rm_rlock .
197The
198.Fa tracker
84.Pp
85Although reader/writer locks look very similar to
86.Xr sx 9
87locks, their usage pattern is different.
88Reader/writer locks can be treated as mutexes (see
89.Xr mutex 9 )
90with shared/exclusive semantics unless initialized with
91.Dv RM_SLEEPABLE .

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

191The
192.Fn rm_wlock
193function cannot be called recursively.
194.It Fn rm_runlock "struct rmlock *rm" "struct rm_priotracker* tracker"
195This function releases a shared lock previously acquired by
196.Fn rm_rlock .
197The
198.Fa tracker
199argument must match the
200.Fa tracker
201argument used for acquiring the shared lock
199argument must match the
200.Fa tracker
201argument used for acquiring the shared lock
202.It Fn rm_wunlock "struct rmlock *rm"
203This function releases an exclusive lock previously acquired by
204.Fn rm_wlock .
205.It Fn rm_destroy "struct rmlock *rm"
206This functions destroys a lock previously initialized with
207.Fn rm_init .
208The
209.Fa rm

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

243can fail transiently even when there is no writer, while another reader
244updates the state on the local CPU.
245.Pp
246The
247.Nm
248implementation uses a single per CPU list shared by all
249rmlocks in the system.
250If rmlocks become popular, hashing to multiple per CPU queues may
202.It Fn rm_wunlock "struct rmlock *rm"
203This function releases an exclusive lock previously acquired by
204.Fn rm_wlock .
205.It Fn rm_destroy "struct rmlock *rm"
206This functions destroys a lock previously initialized with
207.Fn rm_init .
208The
209.Fa rm

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

243can fail transiently even when there is no writer, while another reader
244updates the state on the local CPU.
245.Pp
246The
247.Nm
248implementation uses a single per CPU list shared by all
249rmlocks in the system.
250If rmlocks become popular, hashing to multiple per CPU queues may
251be needed to speed up the writer lock process.
251be needed to speed up the writer lock process.
252.Pp
253The
254.Nm
255can currently not be used as a lock argument for condition variable
256wait functions.
252.Pp
253The
254.Nm
255can currently not be used as a lock argument for condition variable
256wait functions.