Standards / Extensions | C or C++ | Dependencies |
---|---|---|
z/OS UNIX |
both | POSIX(ON) |
#define _OPEN_THREADS
#include <pthread.h>
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
#define _UNIX03_THREADS
#include <pthread.h>
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
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.
If successful, pthread_rwlock_trywrlock() returns 0.
Special behavior for Single UNIX Specification, Version 3: If unsuccessful, pthread_rwlock_trywrlock() returns an error number to indicate the error.