1pthread_rwlock_timedwrlockS(t3aCn)dard C Library Functpitohnrsead_rwlock_timedwrlock(3C)
2
3
4
6 pthread_rwlock_timedwrlock, pthread_rwlock_reltimedwrlock_np - lock a
7 read-write lock for writing
8
10 cc -mt [ flag... ] file... [ library... ]
11 #include <pthread.h>
12 #include <time.h>
13
14 int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rwlock,
15 const struct timespec *restrict abs_timeout);
16
17
18 int pthread_rwlock_reltimedwrlock_np(pthread_rwlock_t *restrict rwlock,
19 const struct timespec *restrict rel_timeout);
20
21
23 The pthread_rwlock_timedwrlock() function applies a write lock to the
24 read-write lock referenced by rwlock as in the
25 pthread_rwlock_wrlock(3C) function. If the lock cannot be acquired
26 without waiting for other threads to unlock the lock, this wait will be
27 terminated when the specified timeout expires. The timeout expires when
28 the absolute time specified by abs_timeout passes, as measured by the
29 CLOCK_REALTIME clock (that is, when the value of that clock equals or
30 exceeds abs_timeout), or if the absolute time specified by abs_timeout
31 has already been passed at the time of the call.
32
33
34 The pthread_rwlock_reltimedwrlock_np() function is identical to the
35 pthread_rwlock_timedwrlock() function, except that the timeout is spec‐
36 ified as a relative time interval. The timeout expires when the time
37 interval specified by rel_timeout passes, as measured by the
38 CLOCK_REALTIME clock, or if the time interval specified by rel_timeout
39 is negative at the time of the call.
40
41
42 The resolution of the timeout is the resolution of the CLOCK_REALTIME
43 clock. The timespec data type is defined in the <time.h> header. Under
44 no circumstances does either function fail with a timeout if the lock
45 can be acquired immediately. The validity of the abs_timeout parameter
46 need not be checked if the lock can be immediately acquired.
47
48
49 If a signal that causes a signal handler to be executed is delivered to
50 a thread blocked on a read- write lock with a call to
51 pthread_rwlock_timedwrlock() or pthread_rwlock_reltimedwrlock_np(),
52 upon return from the signal handler the thread resumes waiting for the
53 lock as if it was not interrupted.
54
55
56 The calling thread can deadlock if at the time the call is made it
57 holds the read-write lock. The results are undefined if this function
58 is called with an uninitialized read-write lock.
59
61 The pthread_rwlock_timedwrlock() and pthread_rwlock_reltimedwrlock_np()
62 functions return 0 if the lock for writing on the read-write lock
63 object referenced by rwlock is acquired. Otherwise, an error number is
64 returned to indicate the error.
65
67 The pthread_rwlock_timedwrlock() and pthread_rwlock_reltimedwrlock_np()
68 functions will fail if:
69
70 ETIMEDOUT The lock could not be acquired before the specified time‐
71 out expired.
72
73
74
75 The pthread_rwlock_timedwrlock() and pthread_rwlock_reltimedwrlock_np()
76 functions may fail if:
77
78 EDEADLK The calling thread already holds the rwlock.
79
80
81 EINVAL The value specified by rwlock does not refer to an initial‐
82 ized read-write lock object, or the timeout nanosecond value
83 is less than zero or greater than or equal to 1,000 million.
84
85
87 See attributes(5) for descriptions of the following attributes:
88
89
90
91
92 ┌─────────────────────────────┬─────────────────────────────┐
93 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
94 ├─────────────────────────────┼─────────────────────────────┤
95 │Interface Stability │See below. │
96 ├─────────────────────────────┼─────────────────────────────┤
97 │MT-Level │MT-Safe │
98 └─────────────────────────────┴─────────────────────────────┘
99
100
101 The pthread_rwlock_timedwrlock() function is Standard. The
102 pthread_rwlock_reltimedwrlock_np() function is Stable.
103
105 pthread_rwlock_destroy(3C), pthread_rwlock_rdlock(3C),
106 pthread_rwlock_timedrdlock(3C), pthread_rwlock_trywrlock(3C),
107 pthread_rwlock_unlock(3C), pthread_rwlock_wrlock(3C), attributes(5),
108 standards(5)
109
110
111
112SunOS 5.11 30 Jan 2004 pthread_rwlock_timedwrlock(3C)