1PTHREAD_RWLOCK_TIMEDRDLOCK(3PPO)SIX Programmer's ManPuTaHlREAD_RWLOCK_TIMEDRDLOCK(3P)
2
3
4

PROLOG

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

NAME

12       pthread_rwlock_timedrdlock — lock a read-write lock for reading
13

SYNOPSIS

15       #include <pthread.h>
16       #include <time.h>
17
18       int pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rwlock,
19           const struct timespec *restrict abstime);
20

DESCRIPTION

22       The pthread_rwlock_timedrdlock() function shall apply a  read  lock  to
23       the    read-write    lock    referenced    by    rwlock   as   in   the
24       pthread_rwlock_rdlock()  function.  However,  if  the  lock  cannot  be
25       acquired  without  waiting  for  other threads to unlock the lock, this
26       wait shall be terminated when the specified timeout expires. The  time‐
27       out shall expire when the absolute time specified by abstime passes, as
28       measured by the clock on which timeouts are based (that  is,  when  the
29       value of that clock equals or exceeds abstime), or if the absolute time
30       specified by abstime has already been passed at the time of the call.
31
32       The timeout shall be based on the CLOCK_REALTIME clock.  The resolution
33       of the timeout shall be the resolution of the CLOCK_REALTIME clock. The
34       timespec data type is defined in the <time.h> header. Under no  circum‐
35       stances  shall  the  function  fail  with  a timeout if the lock can be
36       acquired immediately. The validity of the abstime parameter need not be
37       checked if the lock can be immediately acquired.
38
39       If a signal that causes a signal handler to be executed is delivered to
40       a   thread   blocked   on   a   read-write   lock   via   a   call   to
41       pthread_rwlock_timedrdlock(),  upon  return from the signal handler the
42       thread shall resume waiting for the lock as if it was not interrupted.
43
44       The calling thread may deadlock if at the time  the  call  is  made  it
45       holds  a write lock on rwlock.  The results are undefined if this func‐
46       tion is called with an uninitialized read-write lock.
47

RETURN VALUE

49       The pthread_rwlock_timedrdlock() function shall return zero if the lock
50       for  reading  on  the  read-write  lock  object referenced by rwlock is
51       acquired. Otherwise, an error number shall be returned to indicate  the
52       error.
53

ERRORS

55       The pthread_rwlock_timedrdlock() function shall fail if:
56
57       ETIMEDOUT
58              The  lock  could  not  be  acquired before the specified timeout
59              expired.
60
61       The pthread_rwlock_timedrdlock() function may fail if:
62
63       EAGAIN The read lock could not be acquired because the  maximum  number
64              of read locks for lock would be exceeded.
65
66       EDEADLK
67              A  deadlock condition was detected or the calling thread already
68              holds a write lock on rwlock.
69
70       EINVAL The abstime nanosecond value is less than zero or  greater  than
71              or equal to 1000 million.
72
73       This function shall not return an error code of [EINTR].
74
75       The following sections are informative.
76

EXAMPLES

78       None.
79

APPLICATION USAGE

81       Applications  using this function may be subject to priority inversion,
82       as discussed in the Base Definitions volume  of  POSIX.1‐2017,  Section
83       3.291, Priority Inversion.
84

RATIONALE

86       If  an  implementation  detects  that the value specified by the rwlock
87       argument to pthread_rwlock_timedrdlock() does not refer to an  initial‐
88       ized read-write lock object, it is recommended that the function should
89       fail and report an [EINVAL] error.
90

FUTURE DIRECTIONS

92       None.
93

SEE ALSO

95       pthread_rwlock_destroy(), pthread_rwlock_rdlock(),
96       pthread_rwlock_timedwrlock(), pthread_rwlock_trywrlock(),
97       pthread_rwlock_unlock()
98
99       The Base Definitions volume of POSIX.1‐2017,  Section  3.291,  Priority
100       Inversion, Section 4.12, Memory Synchronization, <pthread.h>, <time.h>
101
103       Portions  of  this text are reprinted and reproduced in electronic form
104       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
105       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
106       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
107       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
108       event of any discrepancy between this version and the original IEEE and
109       The  Open Group Standard, the original IEEE and The Open Group Standard
110       is the referee document. The original Standard can be  obtained  online
111       at http://www.opengroup.org/unix/online.html .
112
113       Any  typographical  or  formatting  errors that appear in this page are
114       most likely to have been introduced during the conversion of the source
115       files  to  man page format. To report such errors, see https://www.ker
116       nel.org/doc/man-pages/reporting_bugs.html .
117
118
119
120IEEE/The Open Group                  2017       PTHREAD_RWLOCK_TIMEDRDLOCK(3P)
Impressum