

The and error checks, if implemented, act as if they were performed immediately at the beginning of processingįor the function and shall cause an error return prior to modifying the state of the mutex specified by mutex. If successful, the pthread_mutex_destroy() and pthread_mutex_init() functions shall return zero otherwise, anĮrror number shall be returned to indicate the error. With parameter attr specified as NULL, except that no error checks are performed. The effect shall be equivalent to dynamic initialization by a call to pthread_mutex_init() In cases where default mutex attributes are appropriate, the macro PTHREAD_MUTEX_INITIALIZER can be used to initialize mutexes To pthread_mutex_lock(), pthread_mutex_trylock(), pthread_mutex_unlock(), and pthread_mutex_destroy() is undefined.Īttempting to initialize an already initialized mutex results in undefined behavior. The result of referring to copies of mutex in calls Only mutex itself may be used for performing synchronization. Upon successful initialization, the state of the mutex becomes initialized and unlocked. If attr is NULL, the default mutex attributes are used the effect shall be the same as passing the address ofĪ default mutex attributes object. The pthread_mutex_init() function shall initialize the mutex referenced by mutex with attributes specified byĪttr. Attempting to destroy a locked mutex results in undefined It shall be safe to destroy an initialized mutex that is unlocked.

Referencing the object after it has been destroyed are undefined.

A destroyed mutex object can be reinitialized using pthread_mutex_init() the results of otherwise An implementation may cause pthread_mutex_destroy() to set the object referenced by mutex The pthread_mutex_destroy() function shall destroy the mutex object referenced by mutex the mutex object becomes, Pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER Int pthread_mutex_init(pthread_mutex_t *restrict mutex ,Ĭonst pthread_mutexattr_t *restrict attr ) Int pthread_mutex_destroy(pthread_mutex_t * mutex )
