1PTHREAD_RWLOCK_TIMEDWRLOCK(3PPO)SIX Programmer's ManPuTaHlREAD_RWLOCK_TIMEDWRLOCK(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_timedwrlock - lock a read-write lock for writing
13

SYNOPSIS

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

DESCRIPTION

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 abs_timeout
29       passes, as measured by the clock on which timeouts are based (that  is,
30       when  the value of that clock equals or exceeds abs_timeout), or if the
31       absolute time specified by abs_timeout has already been passed  at  the
32       time of the call.
33
34       If  the  Timers  option is supported, the timeout shall be based on the
35       CLOCK_REALTIME clock.  If the Timers option is not supported, the time‐
36       out  shall be based on the system clock as returned by the time() func‐
37       tion. The resolution of the timeout shall  be  the  resolution  of  the
38       clock  on  which  it is based. The timespec data type is defined in the
39       <time.h> header. Under no circumstances shall the function fail with  a
40       timeout  if  the  lock can be acquired immediately. The validity of the
41       abs_timeout parameter need not be checked if the lock  can  be  immedi‐
42       ately acquired.
43
44       If a signal that causes a signal handler to be executed is delivered to
45       a   thread   blocked   on   a   read-write   lock   via   a   call   to
46       pthread_rwlock_timedwrlock(),  upon  return from the signal handler the
47       thread shall resume waiting for the lock as if it was not interrupted.
48
49       The calling thread may deadlock if at the time  the  call  is  made  it
50       holds  the  read-write lock. The results are undefined if this function
51       is called with an uninitialized read-write lock.
52

RETURN VALUE

54       The pthread_rwlock_timedwrlock() function shall return zero if the lock
55       for  writing  on  the  read-write  lock  object referenced by rwlock is
56       acquired. Otherwise, an error number shall be returned to indicate  the
57       error.
58

ERRORS

60       The pthread_rwlock_timedwrlock() function shall fail if:
61
62       ETIMEDOUT
63              The  lock  could  not  be  acquired before the specified timeout
64              expired.
65
66
67       The pthread_rwlock_timedwrlock() function may fail if:
68
69       EDEADLK
70              The calling thread already holds the rwlock.
71
72       EINVAL The value specified by rwlock does not refer to  an  initialized
73              read-write  lock  object, or the abs_timeout nanosecond value is
74              less than zero or greater than or equal to 1000 million.
75
76
77       This function shall not return an error code of [EINTR].
78
79       The following sections are informative.
80

EXAMPLES

82       None.
83

APPLICATION USAGE

85       Applications using this function may be subject to priority  inversion,
86       as  discussed  in  the Base Definitions volume of IEEE Std 1003.1-2001,
87       Section 3.285, Priority Inversion.
88
89       The pthread_rwlock_timedwrlock() function is part of  the  Threads  and
90       Timeouts options and need not be provided on all implementations.
91

RATIONALE

93       None.
94

FUTURE DIRECTIONS

96       None.
97

SEE ALSO

99       pthread_rwlock_destroy(), pthread_rwlock_rdlock(), pthread_rwlock_time‐
100       drdlock(),   pthread_rwlock_tryrdlock(),    pthread_rwlock_trywrlock(),
101       pthread_rwlock_unlock(),  pthread_rwlock_wrlock(), the Base Definitions
102       volume of IEEE Std 1003.1-2001, <pthread.h>, <time.h>
103
105       Portions of this text are reprinted and reproduced in  electronic  form
106       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
107       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
108       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
109       Electrical and Electronics Engineers, Inc and The Open  Group.  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.opengroup.org/unix/online.html .
114
115
116
117IEEE/The Open Group                  2003       PTHREAD_RWLOCK_TIMEDWRLOCK(3P)
Impressum