|
Syntax #include <pthread.h> int pthread_rwlock_unlock(pthread_rwlock_t *rwlock); Threadsafe: Yes Signal Safe: Yes |
The pthread_rwlock_unlock() function unlocks a shared read or exclusive write lock held by the calling thread.
A thread should call pthread_rwlock_unlock() once for each time that the thread successfully called pthread_rwlock_rdlock(), pthread_rwlock_tryrdlock(), pthread_rwlock_trywrlock(), pthread_rwlock_timedrdlock_np() or pthread_rwlock_timedwrlock_np() to acquire a shared read or exclusive write lock. I.e. if a thread holds 4 shared read locks on a read/write lock object, the thread must call pthread_rwlock_unlock() 4 times before the read/write lock becomes completely unlocked.
If a thread holds both shared read, and exclusive write locks for the specified read/write lock object, the exclusive write locks are unlocked first. If more than one outstanding exclusive write lock was held by the thread, a matching number of successful calls to pthread_rwlock_unlock() must be done before all write locks are unlocked. When all write locks are unlocked, subsequent calls to pthread_rwlock_unlock() will unlock the shared read locks.
For successful completion, either a shared read or exclusive write lock must be held on the read/write lock prior to calling pthread_rwlock_unlock().
If pthread_rwlock_unlock() was not successful, the error condition returned usually indicates one of the following errors. Under some conditions, the value returned could indicate an error other than those listed here.
See any of the examples for pthread_rwlock_rdlock(), pthread_rwlock_wrlock(), pthread_rwlock_tryrdlock(), pthread_rwlock_trywrlock(), pthread_rwlock_timedrdlock_np(), or pthread_rwlock_timedwrlock_np().