From nobody Fri Oct 08 00:43:17 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 557CD17EA4BB; Fri, 8 Oct 2021 00:43:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HQTv94zfnz3m51; Fri, 8 Oct 2021 00:43:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3A0CB1DB26; Fri, 8 Oct 2021 00:43:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1980hHfN069457; Fri, 8 Oct 2021 00:43:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1980hHLO069456; Fri, 8 Oct 2021 00:43:17 GMT (envelope-from git) Date: Fri, 8 Oct 2021 00:43:17 GMT Message-Id: <202110080043.1980hHLO069456@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 659035b40935 - stable/13 - pthread_mutexattr(3): document each pthread_mutexattr_set/get* function List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 659035b40935e8ea4e11ce8491e6f5233aea5c2f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=659035b40935e8ea4e11ce8491e6f5233aea5c2f commit 659035b40935e8ea4e11ce8491e6f5233aea5c2f Author: Konstantin Belousov AuthorDate: 2021-10-01 01:39:39 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-08 00:42:38 +0000 pthread_mutexattr(3): document each pthread_mutexattr_set/get* function (cherry picked from commit be6116fdfc4d292b77b3df7d4dda029d26a73d65) --- share/man/man3/pthread_mutexattr.3 | 90 +++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 2 deletions(-) diff --git a/share/man/man3/pthread_mutexattr.3 b/share/man/man3/pthread_mutexattr.3 index 41f386804151..2a2c5c8d133e 100644 --- a/share/man/man3/pthread_mutexattr.3 +++ b/share/man/man3/pthread_mutexattr.3 @@ -1,6 +1,11 @@ .\" Copyright (C) 2000 Jason Evans . +.\" Copyright (c) 2021 The FreeBSD Foundation, Inc. .\" All rights reserved. .\" +.\" Part of this documentation was written by +.\" Konstantin Belousov under sponsorship +.\" from the FreeBSD Foundation. +.\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: @@ -102,8 +107,89 @@ function destroys .Fa attr . .Pp The -.Fn pthread_mutexattr_set* -functions set the attribute that corresponds to each function name. +.Fn pthread_mutexattr_setprioceiling +function sets the priority ceiling for the mutex, used +by threads executed under the +.Dv PTHREAD_PRIO_PROTECT +protocol. +.Pp +The +.Fn pthread_mutexattr_setprotocol +function specifies the protocol to be followed in utilizing mutexes. +The +.Fa protocol +argument can take one of the following values: +.Bl -tag -width PTHREAD_PRIO_PROTECT +.It PTHREAD_PRIO_NONE +Priority and scheduling of the thread owning this mutex is not +affected by its mutex ownership. +.It PTHREAD_PRIO_INHERIT +Request priority-inheritance protocol, where the thread owning the mutex +is executed at the highest priority among priorities of all threads waiting +on any mutex owned by this thread. +.It PTHREAD_PRIO_PROTECT +Request priority-inheritance protocol, where the thread owning the mutex +is executed at highest priority among priorities or priority ceilings of +all threads waiting on any mutex owned by this thread. +.El +.Pp +The +.Fn pthread_mutexattr_setrobust +function specifies robustness attribute of the mutex. +Possible values for the +.Fa robust +argument are +.Bl -tag -width PTHREAD_MUTEX_STALLED +.It PTHREAD_MUTEX_STALLED +No special actions are taken if the thread owning the mutex is terminated +without unlocking the mutex lock. +This can lead to deadlocks if no other thread can unlock the mutex. +This is the default value. +.It PTHREAD_MUTEX_ROBUST +If the process containing the owning thread of a robust mutex, or owning +thread, terminates while holding the mutex lock, the next thread that +acquires the mutex is notified about the termination +by the return value +.Ev EOWNERDEAD +from the locking function. +Then, either +.Xr pthread_mutex_consistent 3 +can be used to repair the mutex lock state, or +.Xr pthread_mutex_unlock 3 +can unlock the mutex lock but also put it an unusable state, +where all further attempts to acquire it result in the +.Ev ENOTRECOVERABLE +error. +.El +.Pp +The +.Fn pthread_mutexattr_settype +function sets the type of the mutex. +The type affects the behavior of calls which lock and unlock the mutex. +The possible values for the +.Fa type +argument are +.Bl -tag -width PTHREAD_MUTEX_ERRORCHECK +.It PTHREAD_MUTEX_NORMAL +Both recursive locking, and unlocking when the lock is not owned by the current +thread, cause an error to be returned from the corresponding functions. +This matches +.Dv PTHREAD_MUTEX_ERRORCHECK +but somewhat contradicts the behavior mandated by POSIX. +.It PTHREAD_MUTEX_ERRORCHECK +Both recursive locking, and unlocking when the lock is not owned by the current +thread, cause an error returned from the corresponding functions. +.It PTHREAD_MUTEX_RECURSIVE +Recursive locking is allowed. +Attempt to unlock when current thread is not an owner of the lock causes +an error to be returned. +.It PTHREAD_MUTEX_DEFAULT +The +.Fx +implementation maps this type to +.Dv PTHREAD_MUTEX_ERRORCHECK +type. +.El .Pp The .Fn pthread_mutexattr_get*