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.
#include <thread.h> int mutex_trylock(mutex_t *mp);
mutex_trylock() returns 0 if successful. When any of the following conditions is detected, mutex_trylock() fails and returns the corresponding value.
EFAULT
Description:mp points to an illegal address.
EBUSY
Description:The system detected an attempt to reinitialize an active mutex.