SYNOPSIS
#include <pthread.h>
int pthread_mutex_lock(pthread_mutex_t *mutex);
DESCRIPTION
The
If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection is not provided. Attempting to relock the mutex causes deadlock.
If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error checking is provided. If a thread attempts to relock a mutex that it has already locked, an error is returned.
If the mutex type is PTHREAD_MUTEX_RECURSIVE, the mutex maintains the concept of a lock count. When a thread successfully acquires a mutex for the first time, the lock count is set to one. Every time a thread relocks this mutex, the lock count is incremented by one. The mutex must be unlocked as many time as it was locked for the mutex to be released.
If the mutex type is PTHREAD_MUTEX_DEFAULT, attempting to recursively lock the mutex results in undefined behavior.
PARAMETERS
RETURN VALUES
On success,
- EINVAL
-
mutex is not an initialized mutex.
- EFAULT
-
mutex is an invalid pointer.
- EDEADLK
-
The mutex type is PTHREAD_MUTEX_ERRORCHECK and an attempt was made to relock the mutex.
CONFORMANCE
UNIX 98.
MULTITHREAD SAFETY LEVEL
MT-safe.
PORTING ISSUES
None.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- Functions:
pthread_mutex_init() ,pthread_mutex_trylock() ,pthread_mutex_unlock() ,pthread_mutexattr_settype()
PTC MKS Toolkit 10.5 Documentation Build 40.