pthread_rwlock_tryrdlock()
Attempt to acquire a shared (read) lock on a read-write lock
Synopsis:
#include <pthread.h>
int pthread_rwlock_tryrdlock( pthread_rwlock_t* rwl );
Arguments:
- rwl
- A pointer to a pthread_rwlock_t object that you want to lock for reading.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The pthread_rwlock_tryrdlock() function attempts to acquire a shared (read) lock on the read-write lock referenced by rwl. If the read-write lock is already exclusively locked (i.e., locked for writing), the function returns immediately instead of blocking until a read lock can be obtained; the error it returns depends on whether the lock was exclusively locked by the calling thread or by another thread. If another thread at the same or higher priority is currently waiting to acquire the read-write lock for writing, pthread_rwlock_tryrdlock() returns immediately with an error.
Returns:
- EOK
- Success.
- EAGAIN
- A shared (read) lock couldn't be acquired without exceeding the maximum number of read locks for rwl.
- EBUSY
- One of the following is true:
- The read-write lock was already exclusively locked by another thread.
- The read-write lock is shared-locked and another thread at the same or higher priority is waiting for an exclusive lock.
- EDEADLK
- The calling thread already has an exclusive lock for rwl.
- EFAULT
- A fault occurred when the kernel tried to access rwl.
- EINVAL
- The read-write lock rwl is invalid.
Classification:
| Safety: | |
|---|---|
| Cancellation point | No |
| Signal handler | Yes |
| Thread | Yes |
