1.\" Copyright (c) 2016 The FreeBSD Foundation, Inc.
2.\"
3.\" This documentation was written by
4.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
5.\" from the FreeBSD Foundation.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\" $FreeBSD$
29.\"
30.Dd March 27, 2017
31.Dt PTHREAD_MUTEX_CONSISTENT 3
32.Os
33.Sh NAME
34.Nm pthread_mutex_consistent
35.Nd mark state protected by robust mutex as consistent
36.Sh LIBRARY
37.Lb libpthread
38.Sh SYNOPSIS
39.In pthread.h
40.Ft int
41.Fn pthread_mutex_consistent "pthread_mutex_t *mutex"
42.Sh DESCRIPTION
43If the process containing the thread owning a robust mutex terminates
44while holding the mutex, the mutex becomes inconsistent and the next thread
45that acquires the mutex lock is notified of the state by the return value
46.Er EOWNERDEAD .
47In this case, the mutex does not become normally usable again until
48the state is marked consistent.
49.Pp
50The
51.Fn pthread_mutex_consistent ,
52when called with the
53.Fa mutex
54argument, which points to the initialized robust mutex in an
55inconsistent state, marks the by mutex as consistent again.
56The consequent unlock of the mutex, by either
57.Fn pthread_mutex_unlock
58or other methods, allows other contenders to lock the mutex.
59.Pp
60If the mutex in the inconsistent state is not marked consistent
61by the call to
62.Fn pthread_mutex_consistent
63before unlock,
64further attempts to lock the
65.Fa mutex
66result in the
67.Er ENOTRECOVERABLE
68condition reported by the locking functions.
69.Sh RETURN VALUES
70If successful,
71.Fn pthread_mutex_consistent
72will return zero, otherwise an error number will be returned to
73indicate the error.
74.Sh ERRORS
75The
76.Fn pthread_mutex_lock
77function will fail if:
78.Bl -tag -width Er
79.It Bq Er EINVAL
80The mutex pointed to by the
81.Fa mutex
82argument is not robust, or is not in the inconsistent state.
83.El
84.Sh SEE ALSO
85.Xr pthread_mutex_init 3 ,
86.Xr pthread_mutex_lock 3 ,
87.Xr pthread_mutex_unlock 3 ,
88.Xr pthread_mutexattr_setrobust 3
89.Sh STANDARDS
90The
91.Fn pthread_mutex_lock
92function conforms to
93.St -susv4 .
94