rwlock_init(3synch) rwlock_init(3synch)
NAME
rwlock_init - initialize a reader-writer lock
SYNOPSIS
cc [options] -Kthread file
#include <synch.h>
int rwlock_init(rwlock_t *rwlock, int type, void *arg);
Parameters
rwlock pointer to reader-writer lock to be initialized
type USYNC_THREAD or USYNC_PROCESS
arg NULL (reserved for future use)
DESCRIPTION
rwlock_init initializes the reader-writer lock pointed to by
rwlock to be of type type and in the unlocked state. Once
initialized, the lock can be used any number of times without
being re-initialized.
rwlock Parameter
rwlock points to the reader-writer lock to be initialized.
type Parameter
type can be set to one of the following values:
USYNC_THREAD Initialize the reader-writer lock for threads
within the current process.
USYNC_PROCESS Initialize the reader-writer lock for threads
across processes.
arg Parameter
arg should be set to NULL. It is not currently used, but is
reserved for future use.
Static Reader-Writer Initialization
In this implementation, a reader-writer lock can be
initialized statically if its storage is zero-filled. In this
case, the reader-writer lock is of type USYNC_THREAD, and
rwlock_init need not be called.
Return Values
rwlock_init returns zero for success and an error number for
failure, as described below.
Copyright 1994 Novell, Inc. Page 1
rwlock_init(3synch) rwlock_init(3synch)
Errors
If any of the following conditions is detected, the contents
of rwlock are not changed, and rwlock_init returns the
corresponding value:
EINVAL Invalid type argument specified.
USAGE
Warnings
rwlock_init does not examine the rwlock argument before
initializing it. If rwlock_init is called more than once for
the same reader-writer lock, it will overwrite its state. It
is the user's responsibility to ensure that rwlock_init is
only called once for each reader-writer lock.
Operations on locks initialized with rwlock_init are not
recursive-a thread can deadlock if it attempts to reacquire a
reader-writer lock that it already has acquired.
REFERENCES
rwlock(3synch), rwlock_destroy(3synch), rw_rdlock(3synch),
rw_tryrdlock(3synch), rw_trywrlock(3synch), rw_unlock(3synch),
rw_wrlock(3synch), synch(3synch)
Copyright 1994 Novell, Inc. Page 2