1pthread_rwlock_wrlock(3C)Standard C Library Functionspthread_rwlock_wrlock(3C)
2
3
4
6 pthread_rwlock_wrlock, pthread_rwlock_trywrlock - lock or attempt to
7 lock read-write lock object for writing
8
10 cc -mt [ flag... ] file... -lpthread [ library... ]
11 #include <pthread.h>
12
13 int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
14
15
16 int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
17
18
20 The pthread_rwlock_wrlock() function applies a write lock to the read-
21 write lock referenced by rwlock. The calling thread acquires the write
22 lock if no other thread (reader or writer) holds the read-write lock
23 rwlock. Otherwise, the thread blocks until it can acquire the lock.
24
25
26 The pthread_rwlock_trywrlock() function applies a write lock like the
27 pthread_rwlock_wrlock() function, with the exception that the function
28 fails if any thread currently holds rwlock (for reading or writing).
29
30
31 Writers are favored over readers of the same priority to avoid writer
32 starvation. See pthread_rwlock_rdlock(3C).
33
34
35 Results are undefined if any of these functions are called with an
36 uninitialized read-write lock.
37
38
39 If a signal is delivered to a thread waiting for a read-write lock for
40 writing, upon return from the signal handler the thread resumes waiting
41 for the read-write lock for writing as if it was not interrupted.
42
44 If successful, the pthread_rwlock_wrlock() function returns 0. Other‐
45 wise, an error number is returned to indicate the error.
46
47
48 The pthread_rwlock_trywrlock() function returns 0 if the lock for writ‐
49 ing on the read-write lock object referenced by rwlock is acquired.
50 Otherwise an error number is returned to indicate the error.
51
53 The pthread_rwlock_wrlock() function will fail if:
54
55 EDEADLK The current thread already owns the read-write lock for
56 writing or reading.
57
58
59
60 The pthread_rwlock_trywrlock() function will fail if:
61
62 EBUSY The read-write lock could not be acquired for writing because
63 it was already locked for reading or writing.
64
65
67 See attributes(5) for descriptions of the following attributes:
68
69
70
71
72 ┌─────────────────────────────┬─────────────────────────────┐
73 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
74 ├─────────────────────────────┼─────────────────────────────┤
75 │Interface Stability │Standard │
76 ├─────────────────────────────┼─────────────────────────────┤
77 │MT-Level │MT-Safe │
78 └─────────────────────────────┴─────────────────────────────┘
79
81 pthread_rwlock_init(3C), pthread_rwlock_unlock(3C), pthread_rwlock‐
82 attr_init(3C), pthread_rwlock_rdlock(3C), attributes(5), standards(5)
83
84
85
86SunOS 5.11 23 Mar 2005 pthread_rwlock_wrlock(3C)