Prototype: int pthread_mutex_lock(pthread_mutex_t *mp);
#include <pthread.h> pthread_mutex_t mp; int ret; ret = pthread_ mutex_lock(&mp); /* acquire the mutex */
Use pthread_mutex_lock() to lock the mutex pointed to by mp. When the mutex is already locked, the calling thread blocks and the mutex waits on a prioritized queue. When pthread_mutex_lock() returns, the mutex is locked and the calling thread is the owner.
pthread_mutex_lock() returns zero after completing successfully. Any other returned value indicates that an error occurred. When any of the following conditions occur, the function fails and returns the corresponding value.