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)
|
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)
|