pthread_rwlock_trywrlock(3C) applies a write lock like pthread_rwlock_wrlock(), with the exception that the function fails if any thread currently holds rwlock, for reading or writing.
#include <pthread.h> int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
Results are undefined if pthread_rwlock_trywrlock() is called with an uninitialized read-write lock.
If successful, pthread_rwlock_trywrlock() returns zero if the lock for writing on the read-write lock object referenced by rwlock is acquired. Otherwise, an error number is returned to indicate the error.
EBUSY
Description:The read-write lock could not be acquired for writing because the read-write lock is already locked for reading or writing.