pthread_rwlock_unlock() — Unlock a read or write lock object

Standards

Standards / Extensions C or C++ Dependencies

z/OS UNIX
Single UNIX Specification, Version 3

both

POSIX(ON)
OS/390 V2R7

Format

#define _OPEN_THREADS
#include <pthread.h>

int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
SUSV3:
#define _UNIX03_THREADS
#include <pthread.h>

int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);

General description

The pthread_rwlock_unlock() function releases a read or write lock object. If one or more threads are waiting to lock the rwlock, pthread_rwlock_unlock() causes one or more of these threads to return from the pthread_rwlock_rdlock() or the pthread_rwlock_wrlock() call with the read or write lock object acquired. If there are multiple threads blocked on rwlock for both read locks and write locks, z/OS® UNIX will give the read or write lock to the next waiting call whether it is a read or a write request even when there is a writer blocked waiting for the lock. If no threads are waiting for the rwlock, the rwlock unlocks with no current owner.

Returned value

If successful, pthread_rwlock_unlock() returns 0.

If unsuccessful, pthread_rwlock_unlock() returns -1 and sets errno to one of the following values:
Error Code
Description
EINVAL
The value specified for rwlock is not valid.
ENOMEM
There is not enough memory during the unlock process. This errno will only occur in the private path.
EPERM
The current thread does not own the read_write lock object.

Special behavior for Single UNIX Specification, Version 3: If unsuccessful, pthread_rwlock_unlock() returns an error number to indicate the error.

Related information