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