1951 leaking a vdev when removing an l2cache device
[unleashed.git] / usr / src / man / man3c / pthread_rwlock_timedrdlock.3c
blob4c6270a46c327725a52083a4d7928d40ca98cfc2
1 '\" te
2 .\" Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
3 .\" Portions Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved.
4 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
7 .\"  This notice shall appear on any product containing this material.
8 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
9 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
10 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
11 .TH PTHREAD_RWLOCK_TIMEDRDLOCK 3C "Jan 30, 2004"
12 .SH NAME
13 pthread_rwlock_timedrdlock, pthread_rwlock_reltimedrdlock_np \- lock a
14 read-write lock for reading
15 .SH SYNOPSIS
16 .LP
17 .nf
18 cc \fB-mt\fR [ \fIflag\fR... ] \fIfile\fR... [ \fIlibrary\fR... ]
19 #include <pthread.h>
20 #include <time.h>
22 \fBint\fR \fBpthread_rwlock_timedrdlock\fR(\fBpthread_rwlock_t *restrict\fR \fIrwlock\fR,
23      \fBconst struct timespec *restrict\fR \fIabs_timeout\fR);
24 .fi
26 .LP
27 .nf
28 \fBint\fR \fBpthread_rwlock_reltimedrdlock_np\fR(\fBpthread_rwlock_t *restrict\fR \fIrwlock\fR,
29      \fBconst struct timespec *restrict\fR \fIrel_timeout\fR);
30 .fi
32 .SH DESCRIPTION
33 .sp
34 .LP
35 The \fBpthread_rwlock_timedrdlock()\fR function applies a read lock to the
36 read-write lock referenced by \fIrwlock\fR as in the
37 \fBpthread_rwlock_rdlock\fR(3C) function. If the lock cannot be acquired
38 without waiting for other threads to unlock the lock, this wait will be
39 terminated when the specified timeout expires. The timeout expires when the
40 absolute time specified by \fIabs_timeout\fR passes, as measured by the
41 \fBCLOCK_REALTIME clock\fR (that is, when the value of that clock equals or
42 exceeds \fIabs_timeout\fR), or if the absolute time specified by
43 \fIabs_timeout\fR has already been passed at the time of the call.
44 .sp
45 .LP
46 The \fBpthread_rwlock_reltimedrdlock_np()\fR function is identical to the
47 \fBpthread_rwlock_timedrdlock()\fR function, except that the timeout is
48 specified as a relative time interval.  The timeout expires when the time
49 interval specified by \fIrel_timeout\fR passes, as measured by the
50 \fBCLOCK_REALTIME\fR clock, or if the time interval specified by
51 \fIrel_timeout\fR is negative at the time of the call.
52 .sp
53 .LP
54 The resolution of the timeout is the resolution of the \fBCLOCK_REALTIME\fR
55 clock. The \fBtimespec\fR data type is defined in the <\fBtime.h\fR> header.
56 Under no circumstances does either function fail with a timeout if the lock can
57 be acquired immediately. The validity of the timeout parameter need not be
58 checked if the lock can be immediately acquired.
59 .sp
60 .LP
61 If a signal that causes a signal handler to be executed is delivered to a
62 thread blocked on a read-write lock with a call to
63 \fBpthread_rwlock_timedrdlock()\fR or \fBpthread_rwlock_reltimedrdlock_np()\fR,
64 upon return from the signal handler the thread resumes waiting for the lock as
65 if it was not interrupted.
66 .sp
67 .LP
68 The calling thread might deadlock if at the time the call is made it holds a
69 write lock on rwlock.
70 .sp
71 .LP
72 The results are undefined if this function is called with an uninitialized
73 read-write lock.
74 .SH RETURN VALUES
75 .sp
76 .LP
77 The \fBpthread_rwlock_timedrdlock()\fR and
78 \fBpthread_rwlock_reltimedrdlock_np()\fR functions return 0 if the lock for
79 reading on the read-write lock object referenced by \fIrwlock\fR is acquired.
80 Otherwise, an error number is returned to indicate the error.
81 .SH ERRORS
82 .sp
83 .LP
84 The \fBpthread_rwlock_timedrdlock()\fR and and
85 \fBpthread_rwlock_reltimedrdlock_np()\fR functions will fail if:
86 .sp
87 .ne 2
88 .na
89 \fB\fBETIMEDOUT\fR\fR
90 .ad
91 .RS 13n
92  The lock could not be acquired before the specified timeout expired.
93 .RE
95 .sp
96 .LP
97 The \fBpthread_rwlock_timedrdlock()\fR and
98 \fBpthread_rwlock_reltimedrdlock_np()\fR functions may fail if:
99 .sp
100 .ne 2
102 \fB\fBEAGAIN\fR\fR
104 .RS 11n
105 The read lock could not be acquired because the maximum number of read locks
106 for lock would be exceeded.
110 .ne 2
112 \fB\fBEDEADLK\fR\fR
114 .RS 11n
115 The calling thread already holds a write lock on \fIrwlock\fR.
119 .ne 2
121 \fB\fBEINVAL\fR\fR
123 .RS 11n
124 The value specified by \fIrwlock\fR does not refer to an initialized read-write
125 lock object, or the timeout nanosecond value is less than zero or greater than
126 or equal to 1 000 million.
129 .SH ATTRIBUTES
132 See \fBattributes\fR(5) for descriptions of the following attributes:
137 box;
138 c | c
139 l | l .
140 ATTRIBUTE TYPE  ATTRIBUTE VALUE
142 Interface Stability     See below.
144 MT-Level        MT-Safe
149 The \fBpthread_rwlock_timedrdlock()\fR function is Standard. The
150 \fBpthread_rwlock_reltimedrdlock_np()\fR is Stable.
151 .SH SEE ALSO
154 \fBpthread_rwlock_destroy\fR(3C), \fBpthread_rwlock_rdlock\fR(3C),
155 \fBpthread_rwlock_timedwrlock\fR(3C), \fBpthread_rwlock_trywrlock\fR(3C),
156 \fBpthread_rwlock_unlock\fR(3C), \fBpthread_rwlock_wrlock\fR(3C),
157 \fBattributes\fR(5), \fBstandards\fR(5)