mutex_trylock(SYNCH)
mutex_trylock --
conditionally lock a mutex
Synopsis
cc [options] -Kthread file
#include <synch.h>
int mutex_trylock(mutex_t *mutex);
Description
mutex_trylock attempts once to lock the
mutual exclusion lock (mutex) pointed to by mutex.
Parameters
mutex-
pointer to mutex to be locked
If mutex is available,
mutex_trylock will return successfully
with mutex locked.
If mutex is already locked,
mutex_trylock immediately returns EBUSY to the caller
without acquiring mutex or blocking.
mutex must previously have been initialized,
either by mutex_init, or statically (see
mutex_init(SYNCH)).
Usage
mutex_trylock is used when the caller does not want to block.
Mutexes acquired with mutex_trylock should be released
with mutex_unlock.
Return values
mutex_trylock returns zero for success
and an error number for failure.
Errors
If the following condition occurs,
mutex_trylock returns the corresponding value:
EBUSY-
mutex is already locked
If the following condition is detected,
mutex_trylock fails and returns the corresponding value:
EINVAL-
invalid argument specified
References
Intro(SYNCH),
mutex(SYNCH),
mutex_destroy(SYNCH),
mutex_init(SYNCH),
mutex_lock(SYNCH),
mutex_unlock(SYNCH)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005