rw_unlock(3synch) rw_unlock(3synch)
NAME
rw_unlock - release a reader-writer lock
SYNOPSIS
cc [options] -Kthread file
#include <synch.h>
int rw_unlock(rwlock_t *lock);
Parameters
lock pointer to the lock to be released
DESCRIPTION
rw_unlock releases a reader-writer lock previously acquired by
rw_rdlock, rw_wrlock, rw_tryrdlock, or rw_trywrlock. The
behavior differs according to whether the caller is a reader
or a writer:
When a writer calls rw_unlock, the lock is unlocked.
When a reader calls rw_unlock, the reader count is
decremented. If the reader count is zero, rw_unlock
unlocks the lock, otherwise, the lock is not unlocked.
When rw_unlock unlocks the lock, the first waiter (reader or
writer) is activated.
If the thread activated is a reader, all subsequent
readers are activated (up to the next writer or end of
queue) and the count of readers holding the lock is
changed to reflect this.
If the thread activated is a writer, no other threads
are activated and the lock is marked as being held by a
writer.
lock must previously have been initialized (see rwlock_init).
Return Values
rw_unlock returns zero for success and an error number for
failure, as described below.
Errors
If any of the following conditions is detected, rw_unlock
fails and returns the corresponding value:
Copyright 1994 Novell, Inc. Page 1
rw_unlock(3synch) rw_unlock(3synch)
EINVAL Invalid argument specified.
ENOLCK lock is not locked.
REFERENCES
rwlock(3synch), rwlock_destroy(3synch), rwlock_init(3synch),
rw_rdlock(3synch), rw_tryrdlock(3synch), rw_trywrlock(3synch),
rw_wrlock(3synch), synch(3synch)
Copyright 1994 Novell, Inc. Page 2