PTHREAD_MUTEX_TRYLOCK(3P) SysV PTHREAD_MUTEX_TRYLOCK(3P)
NAME
pthread_mutex_trylock - Tries once to lock a mutex
SYNOPSIS
#include <pthread.h>
int pthread_mutex_trylock (mutex)
pthread_mutex_t *mutex;
DESCRIPTION
The pthread_mutex_trylock function attempts to lock the specified mutex.
If the mutex is already locked, pthread_mutex_trylock returns immediately
indicating the lock failed.
The mutex argument specifies the ID of the mutex to lock.
NOTES
This interface is based on draft 4 of the IEEE P1003.4a standard, and
will be changed to conform to the final version.
DIAGNOSTICS
If the mutex is owned by a thread (which may be the calling thread), a
value of 0 (zero) is returned. If a lock on the mutex is acquired, a
value of 1 is returned. Otherwise, -1 is returned and errno is set to
indicate the error.
ERRORS
If the pthread_mutex_trylock function fails, errno may be set to the
following value:
[EINVAL] The value specified by the mutex argument is invalid.
SEE ALSO
pthread_mutex_init(3P), pthread_mutex_destroy(3P)