rw_trywrlock(3synch) rw_trywrlock(3synch)
NAME
rw_trywrlock - conditionally acquire a reader-writer lock in
write mode
SYNOPSIS
cc [options] -Kthread file
#include <synch.h>
int rw_trywrlock(rwlock_t *lock);
Parameters
lock pointer to the reader-writer lock to be acquired
DESCRIPTION
rw_trywrlock makes a single attempt to acquire the reader-
writer lock pointed to by lock in write mode; it does not
block the caller if the lock is unavailable.
A reader-writer lock can be held by any number of readers at
one time, but only one writer at a time can hold the lock.
If the lock is free, rw_trywrlock acquires the lock in write
mode and the caller proceeds.
If the lock is currently held by a writer, or there are
writers waiting, rw_trywrlock immediately returns EBUSY to the
caller, without acquiring the lock.
lock must previously have been initialized (see rwlock_init).
Return Values
rw_trywrlock returns zero for success and an error number for
failure, as described below.
Errors
If any of the following conditions occurs, rw_trywrlock fails
and returns the corresponding value:
EBUSY The reader-writer lock pointed to by lock cannot be
acquired.
If any of the following conditions is detected, rw_trywrlock
returns the corresponding value:
EINVAL Invalid argument specified.
Copyright 1994 Novell, Inc. Page 1
rw_trywrlock(3synch) rw_trywrlock(3synch)
USAGE
rw_trywrlock is used when the caller does not want to block if
the lock is unavailable.
For consistency, locks acquired with rw_trywrlock should be
released with rw_unlock.
REFERENCES
rwlock(3synch), rwlock_destroy(3synch), rwlock_init(3synch),
rw_rdlock(3synch), rw_tryrdlock(3synch), rw_unlock(3synch),
rw_wrlock(3synch), synch(3synch)
Copyright 1994 Novell, Inc. Page 2