pthread_mutex_init, pthread_mutex_destroy |
Prototype: |
#include <pthread.h>
/*---Predefined mutex settings---*/
pthread_mutex_t fastmutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t recmutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
pthread_mutex_t errchkmutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
int pthread_mutex_init(pthread_mutex_t *mutex,
const pthread_mutexattr_t *mutexattr);
int pthread_mutex_destroy(pthread_mutex_t *mutex);
|
General Description: |
These calls create and destroy mutex semaphore variables. You typically may not need the initializer, because using the defined variables are easier and faster to use. The destroy call normally frees up any resources. However, the Linux implementation uses no allocated resources, so the call does nothing. |
Return Value: |
Always zero. |
Parameters |
mutex |
The mutex to create or destroy. |
mutexattr |
Any attributes to set. If NULL, the call uses the default setting (PTHREAD_MUTEX_INITIALIZER). |
Possible Errors |
(none)
|
|
Examples |
(see pthread_mutex_lock)