Locks an unlocked mutex. If the mutex is already locked, the calling thread blocks until the mutex becomes available.
pthread_mutex_lock( mutex );
Argument Data Type Accessmutex opaque pthread_mutex_t read
#includeint pthread_mutex_lock ( pthread_mutex_t *mutex);
Use the pthread_mutexattr_settype_np routine to set the type of the mutex to normal, recursive, or error-check. For more information about mutexes, see Chapter 2.
The thread that has locked a mutex becomes its current owner and remains the owner until the same thread has unlocked it. This routine returns with the mutex in the locked state and with the current thread as the mutex's current owner.
A recursive or error-check mutex records the identity of the thread that locks it, allowing debuggers to display this information. In most cases, normal mutexes do not record the thread identity.
Return Description0 Successful completion. [EINVAL] The value specified by mutex is invalid, or The mutex was created with the protocol attribute set to PTHREAD_PRIO_PROTECT and the calling thread's priority set higher than the mutex's current priority ceiling. [EDEADLK] A deadlock condition is detected.
pthread_mutexattr_settype_np pthread_mutex_destroy pthread_mutex_init pthread_mutex_trylock pthread_mutex_unlock