rw_tryrdlock(3synch)
rw_tryrdlock --
conditionally acquire a reader-writer lock in read mode
Synopsis
cc [options] -Kthread file
#include <synch.h>
int rw_tryrdlock(rwlock_t *lock);
Description
rw_tryrdlock attempts once to acquire the reader-writer
lock pointed to by lock in read 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
or is currently held by another reader and
there are no writers waiting,
rw_tryrdlock increments the reader count
and the caller proceeds.
If the lock is currently held by a writer,
or there are writers waiting,
rw_tryrdlock immediately returns EBUSY to the caller,
without acquiring the lock.
lock must previously have been initialized
(see rwlock_init(3synch)).
Parameters
lock-
pointer to the lock to be acquired
Usage
rw_tryrdlock is used when the caller does not want to block
if the lock is unavailable.
Return values
rw_tryrdlock returns zero for success
and an error number for failure.
Errors
If the following condition occurs,
rw_tryrdlock fails and returns the corresponding value:
EBUSY-
the reader-writer lock pointed to by lock cannot be acquired
If the following condition is detected,
rw_tryrdlock returns the corresponding value:
EINVAL-
invalid argument specified
For consistency, locks acquired with rw_tryrdlock
should be released with rw_unlock.
References
Intro(3synch),
rwlock(3synch),
rwlock_destroy(3synch),
rwlock_init(3synch),
rw_rdlock(3synch),
rw_trywrlock(3synch),
rw_unlock(3synch),
rw_wrlock(3synch)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004