SYNOPSIS
#include <pthread.h>
int pthread_mutex_unlock(pthread_mutex_t *mutex);
DESCRIPTION
The
If the mutex type is PTHREAD_MUTEX_NORMAL, error detection is not provided. If a thread attempts to unlock a mutex that is has not locked or a mutex which is unlocked, undefined behavior results.
If the mutex type is PTHREAD_MUTEX_ERRORCHECK, error checking is provided. If a thread attempts to unlock a mutex that it has not locked or a mutex that is unlocked, 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. When the lock count reaches zero, the mutex becomes available for other threads to acquire. If a thread attempts to unlock a mutex that it has not locked or a mutex that is unlocked, an error is returned.
If the mutex type is PTHREAD_MUTEX_DEFAULT, attempting to unlock the mutex if it was not locked by the calling thread results in undefined behavior. Attempting to unlock the mutex if it is not locked results in undefined behavior.
PARAMETERS
RETURN VALUES
On success,
- EINVAL
-
mutex is not an initialized mutex.
- EFAULT
-
mutex is an invalid pointer.
- EPERM
-
The calling thread does not own 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_lock() ,pthread_mutex_trylock() ,pthread_mutexattr_settype()
PTC MKS Toolkit 10.5 Documentation Build 40.