Index of Section 2 Manual Pages
| Interix / SUA | pthread_mutex_destroy.2 | Interix / SUA |
pthread_mutex_destroy(2) pthread_mutex_destroy(2)
pthread_mutex_destroy()
NAME
pthread_mutex_destroy(), pthread_mutex_init() - initialize or destroy a
mutex object
SYNOPSIS
#include
int pthread_mutex_destroy(pthread_mutex_t *mutex);
int pthread_mutex_init(pthread_mutex_t *mutex,
const pthread_mutexattr_t *attr);
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
DESCRIPTION
The pthread_mutex_init(2) function initializes the mutex object referenced
by mutex with the attributes specified by the attributes referenced by the
attr argument or with default attributes if attr is null. When the mutex
object is successfully initialized, it is unlocked.
The PTHREAD_MUTEX_INITIALIZER macro can be used to initialize a mutex
object that is statically allocated with default attributes. Using this
macro is equivalent to calling pthread_mutex_init() with a null attr
argument, except that no error checking is performed.
The pthread_mutex_destroy(2) function destroys the mutex object referenced
by the mutex argument. This function should not be called if the specified
mutex is locked by another thread.
RETURN VALUES
On success, both functions return 0; otherwise, an error code is returned.
ERRORS
The pthread_mutex_destroy() function can fail for the following reasons:
[EBUSY]
An attempt was made to destroy the mutex while it is still locked or
referenced by another thread.
[EINVAL]
The mutex argument does not refer to a valid mutex.
The pthread_mutex_init() function can fail for the following reasons:
[EAGAIN]
A required system resource, other than memory, has been exhausted.
[EBUSY]
The specified mutex has already been initialized.
[EINVAL]
The attr argument is invalid.
[ENOMEM]
Not enough free memory exists to initialize the mutex.
[EPERM]
The caller does not have sufficient permissions to perform the
operation.
Neither function returns [EINTR].
SEE ALSO
pthread_mutex_lock(2)
pthread_mutex_timedlock(2)
pthread_mutexattr_getpshared(2)
USAGE NOTES
All of these functions are thread safe.
None of these functions are async-signal safe.