mutex_trylock(3synch) mutex_trylock(3synch)
NAME
mutex_trylock - conditionally lock a mutex
SYNOPSIS
cc [options] -Kthread file
#include <synch.h>
int mutex_trylock(mutex_t *mutex);
Parameters
mutex pointer to mutex to be locked
DESCRIPTION
mutex_trylock attempts once to lock the mutual exclusion lock
(mutex) pointed to by mutex.
If mutex is available, mutex_trylock will return successfully
with mutex locked. If mutex is already locked by another
thread, 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(3synch)].
Return Values
mutex_trylock returns zero for success and an error number for
failure, as described below.
Errors
If any of the following conditions occurs, mutex_trylock
returns the corresponding value:
EBUSY mutex is locked by another thread.
If any of the following conditions is detected, mutex_trylock
fails and returns the corresponding value:
EINVAL Invalid argument specified.
USAGE
mutex_trylock is used when the caller does not want to block.
Mutexes acquired with mutex_trylock should be released with
mutex_unlock.
Copyright 1994 Novell, Inc. Page 1
mutex_trylock(3synch) mutex_trylock(3synch)
REFERENCES
mutex(3synch), mutex_destroy(3synch), mutex_init(3synch),
mutex_lock(3synch), mutex_unlock(3synch), synch(3synch)
Copyright 1994 Novell, Inc. Page 2