1 .\" $NetBSD: pthread_rwlock_rdlock.3,v 1.9 2005/06/17 18:26:53 wiz Exp $
3 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
14 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
15 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
17 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 .\" POSSIBILITY OF SUCH DAMAGE.
25 .\" Copyright (c) 1998 Alex Nash
26 .\" All rights reserved.
28 .\" Redistribution and use in source and binary forms, with or without
29 .\" modification, are permitted provided that the following conditions
31 .\" 1. Redistributions of source code must retain the above copyright
32 .\" notice, this list of conditions and the following disclaimer.
33 .\" 2. Redistributions in binary form must reproduce the above copyright
34 .\" notice, this list of conditions and the following disclaimer in the
35 .\" documentation and/or other materials provided with the distribution.
37 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
38 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
41 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
43 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49 .\" $FreeBSD: src/lib/libpthread/man/pthread_rwlock_rdlock.3,v 1.5 2002/09/16 19:29:29 mini Exp $
52 .Dt PTHREAD_RWLOCK_RDLOCK 3
55 .Nm pthread_rwlock_rdlock ,
56 .Nm pthread_rwlock_timedrdlock ,
57 .Nm pthread_rwlock_tryrdlock
58 .Nd acquire a read/write lock for reading
64 .Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock"
66 .Fn pthread_rwlock_timedrdlock "pthread_rwlock_t * restrict lock" "const struct timespec * restrict abstime"
68 .Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock"
71 .Fn pthread_rwlock_rdlock
72 function acquires a read lock on
76 is not presently held for writing and no writer threads are
77 presently blocked on the lock.
78 If the read lock cannot be immediately acquired, the calling thread
79 blocks until it can acquire the lock.
82 .Fn pthread_rwlock_timedrdlock
83 performs the same action, but will not wait beyond
85 to obtain the lock before returning.
88 .Fn pthread_rwlock_tryrdlock
89 function performs the same action as
90 .Fn pthread_rwlock_rdlock ,
91 but does not block if the lock cannot be immediately obtained (i.e.,
92 the lock is held for writing or there are waiting writers).
94 A thread may hold multiple concurrent read locks.
96 .Fn pthread_rwlock_unlock
97 must be called once for each lock obtained.
99 The results of acquiring a read lock while the calling thread holds
100 a write lock are undefined.
103 .Fn pthread_rwlock_rdlock ,
104 .Fn pthread_rwlock_timedrdlock ,
106 .Fn pthread_rwlock_tryrdlock
107 functions will return zero.
108 Otherwise an error number will be returned to indicate the error.
111 .Fn pthread_rwlock_tryrdlock
112 function shall fail if:
115 The lock could not be acquired because a writer holds the lock or
120 .Fn pthread_rwlock_timedrdlock
121 function shall fail if:
124 The time specified by
126 was reached before the lock could be obtained.
130 .Fn pthread_rwlock_rdlock ,
131 .Fn pthread_rwlock_timedrdlock ,
133 .Fn pthread_rwlock_tryrdlock
134 functions may fail if:
137 The lock could not be acquired because the maximum number of read locks
142 The current thread already owns
146 The value specified by
151 .Xr pthread_rwlock_destroy 3 ,
152 .Xr pthread_rwlock_init 3 ,
153 .Xr pthread_rwlock_unlock 3 ,
154 .Xr pthread_rwlock_wrlock 3
156 .Fn pthread_rwlock_rdlock ,
157 .Fn pthread_rwlock_timedrdlock ,
159 .Fn pthread_rwlock_tryrdlock