1PTHREAD_RWLOCK_TIMEDWRLOCK(PP)OSIX Programmer's ManuPaTlHREAD_RWLOCK_TIMEDWRLOCK(P)
2
3
4
6 pthread_rwlock_timedwrlock - lock a read-write lock for writing
7
9 #include <pthread.h>
10 #include <time.h>
11
12 int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rwlock,
13 const struct timespec *restrict abs_timeout);
14
15
17 The pthread_rwlock_timedwrlock() function shall apply a write lock to
18 the read-write lock referenced by rwlock as in the
19 pthread_rwlock_wrlock() function. However, if the lock cannot be
20 acquired without waiting for other threads to unlock the lock, this
21 wait shall be terminated when the specified timeout expires. The time‐
22 out shall expire when the absolute time specified by abs_timeout
23 passes, as measured by the clock on which timeouts are based (that is,
24 when the value of that clock equals or exceeds abs_timeout), or if the
25 absolute time specified by abs_timeout has already been passed at the
26 time of the call.
27
28 If the Timers option is supported, the timeout shall be based on the
29 CLOCK_REALTIME clock. If the Timers option is not supported, the time‐
30 out shall be based on the system clock as returned by the time() func‐
31 tion. The resolution of the timeout shall be the resolution of the
32 clock on which it is based. The timespec data type is defined in the
33 <time.h> header. Under no circumstances shall the function fail with a
34 timeout if the lock can be acquired immediately. The validity of the
35 abs_timeout parameter need not be checked if the lock can be immedi‐
36 ately acquired.
37
38 If a signal that causes a signal handler to be executed is delivered to
39 a thread blocked on a read-write lock via a call to
40 pthread_rwlock_timedwrlock(), upon return from the signal handler the
41 thread shall resume waiting for the lock as if it was not interrupted.
42
43 The calling thread may deadlock if at the time the call is made it
44 holds the read-write lock. The results are undefined if this function
45 is called with an uninitialized read-write lock.
46
48 The pthread_rwlock_timedwrlock() function shall return zero if the lock
49 for writing on the read-write lock object referenced by rwlock is
50 acquired. Otherwise, an error number shall be returned to indicate the
51 error.
52
54 The pthread_rwlock_timedwrlock() function shall fail if:
55
56 ETIMEDOUT
57 The lock could not be acquired before the specified timeout
58 expired.
59
60
61 The pthread_rwlock_timedwrlock() function may fail if:
62
63 EDEADLK
64 The calling thread already holds the rwlock.
65
66 EINVAL The value specified by rwlock does not refer to an initialized
67 read-write lock object, or the abs_timeout nanosecond value is
68 less than zero or greater than or equal to 1000 million.
69
70
71 This function shall not return an error code of [EINTR].
72
73 The following sections are informative.
74
76 None.
77
79 Applications using this function may be subject to priority inversion,
80 as discussed in the Base Definitions volume of IEEE Std 1003.1-2001,
81 Section 3.285, Priority Inversion.
82
83 The pthread_rwlock_timedwrlock() function is part of the Threads and
84 Timeouts options and need not be provided on all implementations.
85
87 None.
88
90 None.
91
93 pthread_rwlock_destroy() , pthread_rwlock_rdlock() ,
94 pthread_rwlock_timedrdlock() , pthread_rwlock_tryrdlock() ,
95 pthread_rwlock_trywrlock() , pthread_rwlock_unlock() ,
96 pthread_rwlock_wrlock() , the Base Definitions volume of
97 IEEE Std 1003.1-2001, <pthread.h>, <time.h>
98
100 Portions of this text are reprinted and reproduced in electronic form
101 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
102 -- Portable Operating System Interface (POSIX), The Open Group Base
103 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
104 Electrical and Electronics Engineers, Inc and The Open Group. In the
105 event of any discrepancy between this version and the original IEEE and
106 The Open Group Standard, the original IEEE and The Open Group Standard
107 is the referee document. The original Standard can be obtained online
108 at http://www.opengroup.org/unix/online.html .
109
110
111
112IEEE/The Open Group 2003 PTHREAD_RWLOCK_TIMEDWRLOCK(P)