_lwp_mutex_trylock(2)


_lwp_mutex_trylock -- conditionally lock a mutex

Synopsis

   #include <synch.h>
   

int _lwp_mutex_trylock(lwp_mutex_t *mutex);

Parameters


mutex
pointer to mutex to be locked

Description

_lwp_mutex_trylock, is used to conditionally apply a mutual exclusion lock (mutex) on behalf of the calling lightweight process (LWP). The parameter mutex points to the mutex on which the lock is to be applied.

The mutex must previously have been initialized. A lwp_mutex_t object filled with zeros (for example, by static initialization) is a valid unlocked setting. If the mutex is already locked upon entry, the operation immediately returns to the caller without acquiring the lock.

Return values

_lwp_mutex_trylock returns zero on success and an error number for failure, as described below.

Errors

If any of the following conditions is detected, _lwp_mutex_trylock fails and returns the corresponding value:

EINVAL
The mutual exclusion variable pointed to by mutex is invalid.

EFAULT
The mutex parameter points to an illegal address. (This error may not be detected; a SIGSEGV signal may be posted to the faulting LWP if an illegal address is used.)

If any of the following conditions occur, _lwp_mutex_trylock fails and returns the corresponding value:


EBUSY
The parameter mutex points to a locked mutex.

Usage

_lwp_mutex_trylock is used when the caller does not want to block.

For consistency, mutexes acquired with _lwp_mutex_trylock should be released with _lwp_mutex_unlock.

References

_lwp_mutex_lock(2), _lwp_mutex_unlock(2), mutex_destroy(3synch), mutex_init(3synch), mutex_lock(3synch), mutex_trylock(3synch), mutex_unlock(3synch)

Notices

Lightweight processes (LWPs) are internal interfaces and are subject to change. Their use should be avoided.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004