RWLOCK(9)                    OpenBSD Kernel Manual                   RWLOCK(9)

NAME
     rwlock, rw_init, rw_enter_read, rw_enter_write, rw_exit_read,
     rw_exit_write - interface to read/write locks

SYNOPSIS
     #include <sys/rwlock.h>

     void
     rw_init(struct rwlock *rwl, const char *name);

     void
     rw_enter_read(struct rwlock *rwl);

     void
     rw_enter_write(struct rwlock *rwl);

     void
     rw_exit_read(struct rwlock *rwl);

     void
     rw_exit_write(struct rwlock *rwl);

DESCRIPTION
     The rwlock set of functions provides a multiple-reader, single-writer
     locking mechanism to ensure mutual exclusion between different processes.

     The rw_init() function is used to initiate the lock pointed to by rwl.
     The name argument specifies the name of the lock, which is used as the
     wait message if the process needs to sleep.

     The rw_enter_read() function acquires a read lock, sleeping if necessary.

     The rw_enter_write() function acquires a write lock, sleeping if neces-
     sary.

     The rw_exit_read() function releases a read lock.

     The rw_exit_write() function releases a write lock.

     Read locks can be acquired while the write lock is not held, and may co-
     exist in distinct processes at any time.  A write lock, however, can only
     be acquired when there are no read locks held, granting exclusive access
     to a single process.

SEE ALSO
     lockmgr(9), spl(9)

HISTORY
     The rwlock functions first appeared in OpenBSD 3.5.

AUTHORS
     The rwlock functions were written by Artur Grabowski <art@openbsd.org>.

OpenBSD 4.0                     April 19, 2006                               1
