DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

rmutex_trylock(SYNCH)


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(SYNCH)).

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(SYNCH), mutex(SYNCH), rmutex(SYNCH), rmutex_destroy(SYNCH), rmutex_init(SYNCH), rmutex_lock(SYNCH), rmutex_unlock(SYNCH)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005