pthread_mutex_consistent()

Updated: April 19, 2023

Mark as consistent the state that's protected by a mutex

Synopsis:

#include <stdlib.h>

int pthread_mutex_consistent( pthread_mutex_t *mutex);

Arguments:

mutex
A pointer to the pthread_mutex_t object for a robust mutex.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

If mutex is a robust mutex in an inconsistent state, you can use pthread_mutex_consistent() to mark the state protected by the mutex as consistent again. The behavior is undefined if the value specified by mutex argument doesn't refer to an initialized mutex.

If an owner of a robust mutex terminates while holding the mutex, the mutex becomes inconsistent, and the next thread that acquires the mutex lock is notified of the state by a return value EOWNERDEAD from pthread_mutex_lock(), pthread_mutex_timedlock(), or pthread_mutex_trylock(), In this case, the mutex doesn't become normally usable again until the state is marked as consistent.

If the thread that acquired the mutex lock with the return value EOWNERDEAD terminates before calling either pthread_mutex_consistent() or pthread_mutex_unlock(), the next thread that acquires the mutex lock is notified about the state of the mutex by the return value EOWNERDEAD.

Note: The pthread_mutex_consistent() function is responsible only for notifying the implementation that the state protected by the mutex has been recovered and that normal operations with the mutex can be resumed. It's the responsibility of the application to recover the state so it can be reused. If the application can't perform the recovery, it can notify the implementation that the situation is unrecoverable by a call to pthread_mutex_unlock() without a prior call to pthread_mutex_consistent(), in which case subsequent threads that attempt to lock the mutex will fail to acquire the lock and be returned ENOTRECOVERABLE.

Returns:

EOK
Success.
EINVAL
The mutex isn't robust, or it doesn't protect an inconsistent state.

Classification:

POSIX 1003.1

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread No