Index of Section 2 Manual Pages
| Interix / SUA | pthread_rwlock_rdlock.2 | Interix / SUA |
pthread_rwlock_rdlock(2) pthread_rwlock_rdlock(2)
pthread_rwlock_rdlock()
NAME
pthread_rwlock_rdlock(), pthread_rwlock_tryrdlock() - lock a read-write
lock object for reading
SYNOPSIS
#include
int pthread_rwlock_rdlock(pthread_rwlock_t *lock);
int pthread_rwlock_tryrdlock(pthread_rwlock_t *lock);
DESCRIPTION
The pthread_rwlock_rdlock(2) function applies a read lock to the read-
write lock object referenced by the lock argument. The calling thread
acquires the lock if a writer does not hold the lock and no writer is
blocked on the lock. If the read lock is not acquired, then the calling
thread is blocked until it acquires the lock. If the calling thread has a
write lock on the lock object, it can deadlock as a result.
A thread can call pthread_rwlock_rdlock() multiple times for the same lock
object without first releasing the lock object. However, the application
must be sure to call pthread_rwlock_unlock(2) once for each lock that is
acquired.
If a thread is blocked waiting to acquire a read lock and receives a
signal, the thread resumes waiting after the signal handler returns, as
though the signal had not been received.
The pthread_rwlock_tryrdlock(2) function is identical to
pthread_rwlock_rdlock except that the function fails and immediately
returns, and the calling thread is not blocked, if the lock cannot be
acquired.
RETURN VALUES
On success, both functions return 0; otherwise, an error code is returned.
ERRORS
The pthread_rwlock_rdlock() function can fail for the following reason:
[EDEADLK]
The calling thread already has a write lock on the specified read-
write lock object.
The pthread_rwlock_tryrdlock() function can fail for the following reason:
[EBUSY]
The read-write lock could not be acquired for reading because another
thread holds a write lock on the object or a writer is blocked on it.
Both functions can fail for the following reasons:
[EAGAIN]
The lock could not be acquired because the maximum permitted number of
concurrent read locks for the read-write lock object has been reached.
[EINVAL]
The lock argument does not refer to a valid read-write lock object.
Neither function returns [EINTR].
SEE ALSO
pthread_rwlock_destroy(2)
pthread_rwlock_timedrdlock(2)
pthread_rwlock_timedwrlock(2)
pthread_rwlock_trywrlock(2)
pthread_rwlock_unlock(2)
pthread_rwlock_wrlock(2)
USAGE NOTES
All of these functions are thread safe.
None of these functions are async-signal safe.