Use mutex_lock(3C) to lock the mutex pointed to by mp. When the mutex is already locked, the calling thread blocks until the mutex becomes available. Blocked threads wait on a prioritized queue. For POSIX threads, see pthread_mutex_lock Syntax.
#include <thread.h> int mutex_lock(mutex_t *mp);
mutex_lock() returns 0 if successful. When any of the following conditions is detected, mutex_lock() fails and returns the corresponding value.
EFAULT
Description:mp points to an illegal address.
EDEADLK
Description:The mutex is already locked and is owned by the calling thread.