1pthread_rwlock_rdlock(3C)Standard C Library Functionspthread_rwlock_rdlock(3C)
2
3
4

NAME

6       pthread_rwlock_rdlock,  pthread_rwlock_tryrdlock  -  lock or attempt to
7       lock read-write lock object for reading
8

SYNOPSIS

10       cc -mt [ flag... ] file... -lpthread [ library... ]
11       #include <pthread.h>
12
13       int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
14
15
16       int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
17
18

DESCRIPTION

20       The pthread_rwlock_rdlock() function applies a read lock to  the  read-
21       write  lock referenced by rwlock.  The calling thread acquires the read
22       lock if a writer does not hold  the  lock  and  there  are  no  writers
23       blocked on the lock.
24
25
26       The calling thread does not acquire the lock if a writer holds the lock
27       or if writers of higher or equal priority are blocked on the lock; oth‐
28       erwise,  the  calling thread acquires the lock. If the read lock is not
29       acquired, the calling thread blocks until it can acquire the lock.
30
31
32       A thread can hold multiple concurrent read locks on  rwlock  (that  is,
33       successfully call the pthread_rwlock_rdlock() function n times). If so,
34       the thread must perform matching unlocks (that is,  it  must  call  the
35       pthread_rwlock_unlock() function n times).
36
37
38       The  maximum  number of concurrent read locks that a thread can hold on
39       one read-write lock is currently set at  100,000,  though  this  number
40       could change in a future release. There is no imposed limit on the num‐
41       ber of different threads that can apply a read lock to  one  read-write
42       lock.
43
44
45       The  pthread_rwlock_tryrdlock()  function  applies a read lock like the
46       pthread_rwlock_rdlock() function, with the exception that the  function
47       fails if the equivalent pthread_rwlock_rdlock() call would have blocked
48       the calling thread.  In no  case  will  the  pthread_rwlock_tryrdlock()
49       function  ever  bloc.  It  always either acquires the lock or fails and
50       returns immediately.
51
52
53       Results are undefined if any of these  functions  are  called  with  an
54       uninitialized read-write lock.
55
56
57       If  a signal is delivered to a thread waiting for a read-write lock for
58       reading, upon return from the signal handler the thread resumes waiting
59       for the read-write lock for reading as if it was not interrupted.
60

RETURN VALUES

62       If  successful,  the pthread_rwlock_rdlock() function returns 0. Other‐
63       wise, an error number is returned to indicate the error.
64
65
66       The pthread_rwlock_tryrdlock() function returns 0 if the lock for read‐
67       ing  on  the  read-write  lock object referenced by rwlock is acquired.
68       Otherwise an error number  is returned to indicate the error.
69

ERRORS

71       The pthread_rwlock_rdlock()  and  pthread_rwlock_tryrdlock()  functions
72       will fail if:
73
74       EAGAIN    The  read lock could not be acquired because the maximum num‐
75                 ber of read locks by the current thread for rwlock  has  been
76                 exceeded.
77
78
79
80       The pthread_rwlock_rdlock() function will fail if:
81
82       EDEADLK    The  current  thread  already  owns  the read-write lock for
83                  writing.
84
85
86
87       The pthread_rwlock_tryrdlock() function will fail if:
88
89       EBUSY    The read-write lock could not be acquired for reading  because
90                a  writer holds the lock or a writer with the appropriate pri‐
91                ority was blocked on it.
92
93

ATTRIBUTES

95       See  attributes(5) for descriptions of the following attributes:
96
97
98
99
100       ┌─────────────────────────────┬─────────────────────────────┐
101       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
102       ├─────────────────────────────┼─────────────────────────────┤
103       │Interface Stability          │Standard                     │
104       ├─────────────────────────────┼─────────────────────────────┤
105       │MT-Level                     │MT-Safe                      │
106       └─────────────────────────────┴─────────────────────────────┘
107

SEE ALSO

109       pthread_rwlock_init(3C),   pthread_rwlock_wrlock(3C),   pthread_rwlock‐
110       attr_init(3C), pthread_rwlock_unlock(3C), attributes(5), standards(5)
111
112
113
114SunOS 5.11                        23 Mar 2005        pthread_rwlock_rdlock(3C)
Impressum