1PTHREAD_RWLOCK_TIMEDWRLOCK(3PPO)SIX Programmer's ManPuTaHlREAD_RWLOCK_TIMEDWRLOCK(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 pthread_rwlock_timedwrlock — lock a read-write lock for writing
14
16 #include <pthread.h>
17 #include <time.h>
18
19 int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rwlock,
20 const struct timespec *restrict abstime);
21
23 The pthread_rwlock_timedwrlock() function shall apply a write lock to
24 the read-write lock referenced by rwlock as in the
25 pthread_rwlock_wrlock() function. However, if the lock cannot be
26 acquired without waiting for other threads to unlock the lock, this
27 wait shall be terminated when the specified timeout expires. The time‐
28 out shall expire when the absolute time specified by abstime passes, as
29 measured by the clock on which timeouts are based (that is, when the
30 value of that clock equals or exceeds abstime), or if the absolute time
31 specified by abstime has already been passed at the time of the call.
32
33 The timeout shall be based on the CLOCK_REALTIME clock. The resolution
34 of the timeout shall be the resolution of the CLOCK_REALTIME clock. The
35 timespec data type is defined in the <time.h> header. Under no circum‐
36 stances shall the function fail with a timeout if the lock can be
37 acquired immediately. The validity of the abstime parameter need not be
38 checked if the lock can be immediately acquired.
39
40 If a signal that causes a signal handler to be executed is delivered to
41 a thread blocked on a read-write lock via a call to
42 pthread_rwlock_timedwrlock(), upon return from the signal handler the
43 thread shall resume waiting for the lock as if it was not interrupted.
44
45 The calling thread may deadlock if at the time the call is made it
46 holds the read-write lock. The results are undefined if this function
47 is called with an uninitialized read-write lock.
48
50 The pthread_rwlock_timedwrlock() function shall return zero if the lock
51 for writing on the read-write lock object referenced by rwlock is
52 acquired. Otherwise, an error number shall be returned to indicate the
53 error.
54
56 The pthread_rwlock_timedwrlock() function shall fail if:
57
58 ETIMEDOUT
59 The lock could not be acquired before the specified timeout
60 expired.
61
62 The pthread_rwlock_timedwrlock() function may fail if:
63
64 EDEADLK
65 A deadlock condition was detected or the calling thread already
66 holds the rwlock.
67
68 EINVAL The abstime nanosecond value is less than zero or greater than
69 or equal to 1000 million.
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 POSIX.1‐2008, Section
81 3.287, Priority Inversion.
82
84 If an implementation detects that the value specified by the rwlock
85 argument to pthread_rwlock_timedwrlock() does not refer to an initial‐
86 ized read-write lock object, it is recommended that the function should
87 fail and report an [EINVAL] error.
88
90 None.
91
93 pthread_rwlock_destroy(), pthread_rwlock_rdlock(), pthread_rwlock_time‐
94 drdlock(), pthread_rwlock_trywrlock(), pthread_rwlock_unlock()
95
96 The Base Definitions volume of POSIX.1‐2008, Section 3.287, Priority
97 Inversion, Section 4.11, Memory Synchronization, <pthread.h>, <time.h>
98
100 Portions of this text are reprinted and reproduced in electronic form
101 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
102 -- Portable Operating System Interface (POSIX), The Open Group Base
103 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
104 cal and Electronics Engineers, Inc and The Open Group. (This is
105 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
106 event of any discrepancy between this version and the original IEEE and
107 The Open Group Standard, the original IEEE and The Open Group Standard
108 is the referee document. The original Standard can be obtained online
109 at http://www.unix.org/online.html .
110
111 Any typographical or formatting errors that appear in this page are
112 most likely to have been introduced during the conversion of the source
113 files to man page format. To report such errors, see https://www.ker‐
114 nel.org/doc/man-pages/reporting_bugs.html .
115
116
117
118IEEE/The Open Group 2013 PTHREAD_RWLOCK_TIMEDWRLOCK(3P)