1 .\" $NetBSD: pthread_rwlock_wrlock.3,v 1.7 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_wrlock.3,v 1.5 2002/09/16 19:29:29 mini Exp $
52 .Dt PTHREAD_RWLOCK_WRLOCK 3
55 .Nm pthread_rwlock_wrlock ,
56 .Nm pthread_rwlock_timedwrlock ,
57 .Nm pthread_rwlock_trywrlock
58 .Nd acquire a read/write lock for writing
64 .Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock"
66 .Fn pthread_rwlock_timedwrlock "pthread_rwlock_t * restrict lock" "const struct timespec * restrict abstime"
68 .Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock"
71 .Fn pthread_rwlock_wrlock
72 function blocks until a write lock can be acquired against
76 .Fn pthread_rwlock_timedwrlock
77 performs the same action, but will not wait beyond
79 to obtain the lock before returning.
82 .Fn pthread_rwlock_trywrlock
83 function performs the same action as
84 .Fn pthread_rwlock_wrlock ,
85 but does not block if the lock cannot be immediately obtained.
87 The results are undefined if the calling thread already holds the
88 lock at the time the call is made.
91 .Fn pthread_rwlock_wrlock ,
92 .Fn pthread_rwlock_timedwrlock ,
94 .Fn pthread_rwlock_trywrlock
95 functions will return zero.
96 Otherwise an error number will be returned to indicate the error.
99 .Fn pthread_rwlock_trywrlock
100 function shall fail if:
103 The calling thread is not able to acquire the lock without blocking.
107 .Fn pthread_rwlock_timedrdlock
108 function shall fail if:
111 The time specified by
113 was reached before the lock could be obtained.
117 .Fn pthread_rwlock_wrlock ,
118 .Fn pthread_rwlock_timedwrlock ,
120 .Fn pthread_rwlock_trywrlock
121 functions may fail if:
124 The calling thread already owns the read/write lock (for reading
127 The value specified by
132 .Xr pthread_rwlock_destroy 3 ,
133 .Xr pthread_rwlock_init 3 ,
134 .Xr pthread_rwlock_rdlock 3 ,
135 .Xr pthread_rwlock_unlock 3
137 .Fn pthread_rwlock_wrlock ,
138 .Fn pthread_rwlock_timedwrlock ,
140 .Fn pthread_rwlock_trywrlock