Trying to Acquire a Mutex
Use mutex_trylock(3C) to attempt to lock the mutex pointed to by mp. This function is a nonblocking version of mutex_lock().
For POSIX threads, see pthread_mutex_trylock Syntax.
int mutex_trylock(mutex_t *mp);
mutex_trylock Return Values
mutex_trylock() returns 0
if successful. When any of the following conditions is detected, mutex_trylock() fails and returns the corresponding value.
mp points to
an illegal address.
The system detected an attempt to reinitialize
an active mutex.