Index of Section 2 Manual Pages
| Interix / SUA | pthread_rwlock_wrlock.2 | Interix / SUA |
pthread_rwlock_wrlock(2) pthread_rwlock_wrlock(2)
pthread_rwlock_wrlock()
NAME
pthread_rwlock_wrlock(), pthread_rwlock_trywrlock() - lock a read-write
lock object for writing
SYNOPSIS
#include
int pthread_rwlock_wrlock(pthread_rwlock_t *lock);
int pthread_rwlock_trywrlock(pthread_rwlock_t *lock);
DESCRIPTION
The pthread_rwlock_wrlock(2) function applies a write lock to the read-
write lock object referenced by the lock argument. The calling thread
acquires the lock if a thread (either a reader or a writer) does not hold
the lock and no thread is blocked on the lock. If the write lock is not
acquired, then the calling thread is blocked until it acquires the lock.
If the calling thread has a read or write lock on the lock object, it can
deadlock as a result.
If a thread is blocked waiting to acquire a write 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_trywrlock(2) function is identical to
pthread_rwlock_wrlock 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_wrlock() function can fail for the following reason:
[EDEADLK]
The calling thread already has a read or write lock on the specified
read-write lock object.
The pthread_rwlock_trywrlock() function can fail for the following reason:
[EBUSY]
The read-write lock could not be acquired for reading because another
thread holds a read or write lock on the object or a thread (reader or
writer) is blocked on it.
Both functions can fail for the following reason:
[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_rdlock(2)
pthread_rwlock_timedrdlock(2)
pthread_rwlock_timedwrlock(2)
pthread_rwlock_tryrdlock(2)
pthread_rwlock_unlock(2)
USAGE NOTES
All of these functions are thread safe.
None of these functions are async-signal safe.