1PTHREAD_RWLOCK_TIMEDRDLOCK(3PPO)SIX Programmer's ManPuTaHlREAD_RWLOCK_TIMEDRDLOCK(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_timedrdlock — lock a read-write lock for reading
14
16 #include <pthread.h>
17 #include <time.h>
18
19 int pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rwlock,
20 const struct timespec *restrict abstime);
21
23 The pthread_rwlock_timedrdlock() function shall apply a read lock to
24 the read-write lock referenced by rwlock as in the
25 pthread_rwlock_rdlock() 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_timedrdlock(), 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 a write lock on rwlock. The results are undefined if this func‐
47 tion is called with an uninitialized read-write lock.
48
50 The pthread_rwlock_timedrdlock() function shall return zero if the lock
51 for reading 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_timedrdlock() 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_timedrdlock() function may fail if:
63
64 EAGAIN The read lock could not be acquired because the maximum number
65 of read locks for lock would be exceeded.
66
67 EDEADLK
68 A deadlock condition was detected or the calling thread already
69 holds a write lock on rwlock.
70
71 EINVAL The abstime nanosecond value is less than zero or greater than
72 or equal to 1000 million.
73
74 This function shall not return an error code of [EINTR].
75
76 The following sections are informative.
77
79 None.
80
82 Applications using this function may be subject to priority inversion,
83 as discussed in the Base Definitions volume of POSIX.1‐2008, Section
84 3.287, Priority Inversion.
85
87 If an implementation detects that the value specified by the rwlock
88 argument to pthread_rwlock_timedrdlock() does not refer to an initial‐
89 ized read-write lock object, it is recommended that the function should
90 fail and report an [EINVAL] error.
91
93 None.
94
96 pthread_rwlock_destroy(), pthread_rwlock_rdlock(),
97 pthread_rwlock_timedwrlock(), pthread_rwlock_trywrlock(),
98 pthread_rwlock_unlock()
99
100 The Base Definitions volume of POSIX.1‐2008, Section 3.287, Priority
101 Inversion, Section 4.11, Memory Synchronization, <pthread.h>, <time.h>
102
104 Portions of this text are reprinted and reproduced in electronic form
105 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
106 -- Portable Operating System Interface (POSIX), The Open Group Base
107 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
108 cal and Electronics Engineers, Inc and The Open Group. (This is
109 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
110 event of any discrepancy between this version and the original IEEE and
111 The Open Group Standard, the original IEEE and The Open Group Standard
112 is the referee document. The original Standard can be obtained online
113 at http://www.unix.org/online.html .
114
115 Any typographical or formatting errors that appear in this page are
116 most likely to have been introduced during the conversion of the source
117 files to man page format. To report such errors, see https://www.ker‐
118 nel.org/doc/man-pages/reporting_bugs.html .
119
120
121
122IEEE/The Open Group 2013 PTHREAD_RWLOCK_TIMEDRDLOCK(3P)