|
|
cc [options] -Kthread file#include <synch.h>
int rw_wrlock(rwlock_t *lock);
Only one writer at a time can hold a reader-writer lock, although any number of readers can hold the lock at any time. Once a writer has requested the lock with rw_wrlock, all subsequent requests for the lock in either read or write mode are blocked.
When no other readers or writers hold the lock, rw_wrlock will acquire the lock, and the caller will proceed. Any other write and read requests for the lock will block until the caller unlocks the lock with rw_unlock(3synch).
If the lock is held by any readers when rw_wrlock is called, and no writer is waiting for the lock, the caller blocks until all the current readers have released the lock. If the lock is held by another writer, or if there are any other writers already waiting for the lock, the caller blocks to wait for the lock.
lock must previously have been initialized (see rwlock_init(3synch)).
From the point of view of the application, this function is atomic: even if interrupted by a signal or forkall, rw_wrlock will not return until it holds the lock. As a consequence, if rw_wrlock is interrupted, an error indication such as EINTR is never returned to the user.