DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

pthread_rwlock_unlock(3pthread)


pthread_rwlock_unlock -- release a read-write lock

Synopsis

   cc [options] -Kthread file
   

#include <pthread.h>

int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);

Description

pthread_rwlock_unlock releases a reader-writer lock previously acquired by pthread_rwlock_rdlock, pthread_rwlock_wrlock, pthread_rwlock_tryrdlock, or pthread_rwlock_trywrlock. The behavior differs according to whether the caller is a reader or a writer:

When pthread_rwlock_unlock unlocks the lock, the first waiter (reader or writer) is activated.

If pthread_rwlock_unlock releases the last read lock for this read-write lock object, the read-write lock object will be put in the unlocked state with no owners.

If pthread_rwlock_unlock is called to release a write lock for this read-write lock object, the read-write lock object will be put in the unlocked state with no owners.

If the call to pthread_rwlock_unlock results in the read-write lock object becoming unlocked and there are multiple threads waiting to acquire the read-write lock object for writing, the scheduling policy is used to determine which thread acquires the read-write lock object for writing. If there are multiple threads waiting to acquire the read-write lock object for reading, threads are awakened in the order in which they arrived (that is, FIFO order).

Results are undefined if pthread_rwlock_unlock is called with an uninitialized or unlocked read-write lock.

The rwlock parameter is a pointer to the lock to be released.

Return values

pthread_rwlock_unlock returns zero on success. Otherwise, an error number is returned.

Diagnostics

rw_unlock returns the following values if the corresponding conditions are detected:

EINVAL
Invalid argument specified. The value specified by rwlock does not refer to an initialized read-write lock object.

ENOLCK
rwlock not locked.

Standards compliance

The Single UNIX Specification, Version 2; The Open Group.

References

Intro(3pthread), pthread(4), pthread_rwlockattr_init(3pthread), pthread_rwlock_init(3pthread), pthread_rwlock_rdlock(3pthread), pthread_rwlock_wrlock(3pthread)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004