pthread_rwlock_unlock()--Unlock Exclusive Write or Shared Read Lock


  Syntax:
 #include <pthread.h>
 int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);   
  Service Program Name: QP0WPTHR

  Default Public Authority: *USE

  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. For example, 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() unlock the shared read locks.


Authorities and Locks

For successful completion, either a shared read or exclusive write lock must be held on the read/write lock before you call pthread_rwlock_unlock().


Parameters

rwlock
(Input) The address of the read/write lock

Return Value

0
pthread_rwlock_unlock() was successful.
value
pthread_rwlock_unlock() was not successful. value is set to indicate the error condition.

Error Conditions

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.

[EINVAL]

The value specified for the argument is not correct.

[EPERM]

A shared read or exclusive write lock was not held by the calling thread and could not be unlocked.


Related Information


Example

See Code disclaimer information for information pertaining to code examples.

See any of the following examples:


API introduced: V4R3
Top | Pthread APIs | APIs by category