pthread_rwlock_trywrlock() — Attempt to lock a read or write lock object for writing
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS UNIX |
both | POSIX(ON) |
Format
#define _OPEN_THREADS
#include <pthread.h>
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
SUSV3:
#define _UNIX03_THREADS
#include <pthread.h>
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
General description
The pthread_rwlock_trywrlock() function applies a write lock as in the pthread_rwlock_wrlock() function with the exception that the function fails if any thread holds either a read lock or a write lock on rwlock. Read/write locks are used to protect shared resources.
If the read or write lock identified by rwlock is locked, pthread_rwlock_trywrlock() returns immediately.
Returned value
If successful, pthread_rwlock_trywrlock() returns 0.
If unsuccessful, pthread_rwlock_trywrlock() returns
-1 and sets errno to one of the following values:
- Error Code
- Description
- EBUSY
- rwlock could not be acquired because it was already locked.
- EINVAL
- The value specified by rwlock is not valid.
- ENOMEM
- There is not enough memory to acquire a lock. This errno will only occur in the private path.
Special behavior for Single UNIX Specification, Version 3: If unsuccessful, pthread_rwlock_trywrlock() returns an error number to indicate the error.