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 .LP
  69 The \fBpthread_rwlock_timedwrlock()\fR function applies a write lock to the
  70 read-write lock referenced by \fIrwlock\fR as in the
  71 \fBpthread_rwlock_wrlock\fR(3C) function. If the lock cannot be acquired
  72 without waiting for other threads to unlock the lock, this wait will be
  73 terminated when the specified timeout expires. The timeout expires when the
  74 absolute time specified by \fIabs_timeout\fR passes, as measured by the
  75 \fBCLOCK_REALTIME\fR clock (that is, when the value of that clock equals or
  76 exceeds \fIabs_timeout\fR), or if the absolute time specified by
  77 \fIabs_timeout\fR has already been passed at the time of the call.
  78 .sp
  79 .LP
  80 The \fBpthread_rwlock_reltimedwrlock_np()\fR function is identical to the
  81 \fBpthread_rwlock_timedwrlock()\fR function, except that the timeout is
  82 specified as a relative time interval. The timeout expires when the time
  83 interval specified by \fIrel_timeout\fR passes, as measured by the
  84 \fBCLOCK_REALTIME\fR clock, or if the time interval specified by
  85 \fIrel_timeout\fR is negative at the time of the call.
  86 .sp
  87 .LP
  88 The resolution of the timeout is the resolution of the \fBCLOCK_REALTIME\fR
  89 clock. The \fBtimespec\fR data type is defined in the <\fBtime.h\fR> header.
  90 Under no circumstances does either function fail with a timeout if the lock can
  91 be acquired immediately. The validity of the \fIabs_timeout\fR parameter need
  92 not be checked if the lock can be immediately acquired.
  93 .sp
  94 .LP
  95 If a signal that causes a signal handler to be executed is delivered to a
  96 thread blocked on a read- write lock with a call to
  97 \fBpthread_rwlock_timedwrlock()\fR or \fBpthread_rwlock_reltimedwrlock_np()\fR,
  98 upon return from the signal handler the thread resumes waiting for the lock as
  99 if it was not interrupted.
 100 .sp
 101 .LP
 102 The calling thread can deadlock if at the time the call is made it holds the
 103 read-write lock. The results are undefined if this function is called with an
 104 uninitialized read-write lock.
 105 .SH RETURN VALUES
 106 .LP
 107 The \fBpthread_rwlock_timedwrlock()\fR and
 108 \fBpthread_rwlock_reltimedwrlock_np()\fR functions return 0 if the lock for
 109 writing on the read-write lock object referenced by \fIrwlock\fR is acquired.
 110 Otherwise, an error number is returned to indicate the error.
 111 .SH ERRORS
 112 .LP
 113 The \fBpthread_rwlock_timedwrlock()\fR and
 114 \fBpthread_rwlock_reltimedwrlock_np()\fR functions will fail if:
 115 .sp
 116 .ne 2
 117 .na
 118 \fB\fBETIMEDOUT\fR\fR
 119 .ad
 120 .RS 13n
 121 The lock could not be acquired before the specified timeout expired.
 122 .RE
 123 
 124 .sp
 125 .LP
 126 The \fBpthread_rwlock_timedwrlock()\fR and
 127 \fBpthread_rwlock_reltimedwrlock_np()\fR functions may fail if:
 128 .sp
 129 .ne 2
 130 .na
 131 \fB\fBEDEADLK\fR\fR
 132 .ad
 133 .RS 11n
 134 The calling thread already holds the rwlock.
 135 .RE
 136 
 137 .sp
 138 .ne 2
 139 .na
 140 \fB\fBEINVAL\fR\fR
 141 .ad
 142 .RS 11n
 143 The value specified by \fIrwlock\fR does not refer to an initialized read-write
 144 lock object, or the timeout nanosecond value is less than zero or greater than
 145 or equal to 1,000 million.
 146 .RE
 147 
 148 .SH ATTRIBUTES
 149 .LP
 150 See \fBattributes\fR(5) for descriptions of the following attributes:
 151 .sp
 152 
 153 .sp
 154 .TS
 155 box;
 156 c | c
 157 l | l .
 158 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 159 _
 160 Interface Stability     See below.
 161 _
 162 MT-Level        MT-Safe
 163 .TE
 164 
 165 .sp
 166 .LP
 167 The \fBpthread_rwlock_timedwrlock()\fR function is Standard. The
 168 \fBpthread_rwlock_reltimedwrlock_np()\fR function is Stable.
 169 .SH SEE ALSO
 170 .LP
 171 \fBpthread_rwlock_destroy\fR(3C), \fBpthread_rwlock_rdlock\fR(3C),
 172 \fBpthread_rwlock_timedrdlock\fR(3C), \fBpthread_rwlock_trywrlock\fR(3C),
 173 \fBpthread_rwlock_unlock\fR(3C), \fBpthread_rwlock_wrlock\fR(3C),
 174 \fBattributes\fR(5), \fBstandards\fR(5)