rmutex_trylock(3synch)
rmutex_trylock --
conditionally lock a recursive mutex
Synopsis
cc [options] -Kthread file
#include <synch.h>
int rmutex_trylock(rmutex_t *rmutex);
Description
rmutex_trylock attempts once to lock the
recursive mutual exclusion lock (rmutex) pointed to by rmutex.
If rmutex is available,
rmutex_trylock will return successfully
with rmutex locked.
If rmutex is already locked by another thread,
rmutex_trylock immediately returns EBUSY to the caller
without locking rmutex or blocking.
If rmutex is already held by the calling thread,
the recursive depth is incremented and control is returned
to the caller,
as if the lock had just been acquired.
rmutex must previously have been initialized
(see rmutex_init(3synch)).
Parameters
- rmutex
-
pointer to recursive mutex to be locked
Usage
rmutex_trylock is used when the caller does not want to block.
The locks acquired with rmutex_trylock should be released
with rmutex_unlock.
Return values
rmutex_trylock returns zero for success
and an error number for failure.
Errors
If any of the following conditions is detected,
rmutex_trylock returns the corresponding value:
- EBUSY
-
rmutex is locked by another thread
- EINVAL
-
invalid argument specified
References
Intro(3synch),
mutex(3synch),
rmutex(3synch),
rmutex_destroy(3synch),
rmutex_init(3synch),
rmutex_lock(3synch),
rmutex_unlock(3synch)
30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.