.\"Copyright (c) 2010 Novell Inc., written by Robert Schweikert .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH PTHREAD_RWLOCKATTR_SETKIND_NP 3 2020\-08\-13 "Linux Programmer's Manual" .SH 名前 pthread_rwlockattr_setkind_np, pthread_rwlockattr_getkind_np \- スレッドの読み書きロック属性オブジェクトの読み書きロック種別の設定、取得を行う .SH 書式 .nf \fB#include \fP .PP \fBint pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *\fP\fIattr\fP\fB,\fP \fB int \fP\fIpref\fP\fB);\fP \fBint pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *\fP\fIattr\fP\fB,\fP \fB int *\fP\fIpref\fP\fB);\fP .PP \fI\-pthread\fP でコンパイルしてリンクする。 .PP .fi .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBpthread_rwlockattr_setkind_np\fP(), \fBpthread_rwlockattr_getkind_np\fP(): .br .RS 4 .ad l _XOPEN_SOURCE\ >=\ 500 || _POSIX_C_SOURCE >= 200809L .RE .ad .SH 説明 \fBpthread_rwlockattr_setkind_np\fP() 関数は、 \fIattr\fP が参照する読み書きロック属性オブジェクトの「ロック種別 (lock kind)」を \fIpref\fP で指定された値に設定する。 引数 \fIpref\fP には以下のいずれか一つを設定できる。 .TP \fBPTHREAD_RWLOCK_PREFER_READER_NP\fP これがデフォルトである。 スレッドは複数の読み出しロックを保持できる。 つまり、読み出しロックは再帰的である。 Single Unix Specification では、 読み出し側がロックをかけようとした際に、書き込みロックはないが書き込み側が待っていた場合の、動作は規定されていない。 \fBPTHREAD_RWLOCK_PREFER_READER_NP\fP に設定し、読み出し側に優先度を与えるということは、 たとえ書き込み側が待っていたとしても、読み出し側が要求したロックを受け取ることを意味する。 読み出し側がいる限り、書き込み側は待つことになる。 .TP \fBPTHREAD_RWLOCK_PREFER_WRITER_NP\fP .\" --- .\" Here is the relevant wording: .\" .\" A thread may hold multiple concurrent read locks on rwlock (that is, .\" successfully call the pthread_rwlock_rdlock() function n times). If .\" so, the thread must perform matching unlocks (that is, it must call .\" the pthread_rwlock_unlock() function n times). .\" .\" By making write-priority work correctly, I broke the above requirement, .\" because I had no clue that recursive read locks are permissible. .\" .\" If a thread which holds a read lock tries to acquire another read lock, .\" and now one or more writers is waiting for a write lock, then the algorithm .\" will lead to an obvious deadlock. The reader will be suspended, waiting for .\" the writers to acquire and release the lock, and the writers will be .\" suspended waiting for every existing read lock to be released. .\" --- .\" https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html .\" https://sourceware.org/legacy-ml/libc-alpha/2000-01/msg00055.html .\" https://sourceware.org/bugzilla/show_bug.cgi?id=7057 This is intended as the write lock analog of \fBPTHREAD_RWLOCK_PREFER_READER_NP\fP. This is ignored by glibc because the POSIX requirement to support recursive read locks would cause this option to create trivial deadlocks; instead use \fBPTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\fP which ensures the application developer will not take recursive read locks thus avoiding deadlocks. .TP \fBPTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\fP ロック種別をこの値に設定すると、 読み出しロックが再帰的に行われない限りは、 書き込み側の待ちを避けることができる。 .PP \fBpthread_rwlockattr_getkind_np\fP() 関数は、 \fIattr\fP が参照する読み書きロック属性オブジェクトのロック種別属性の値をポインター \fIpref\fP に入れて返す。 .SH 返り値 成功すると、これらの関数は 0 を返す。 有効なポインター引数が渡された場合、 \fBpthread_rwlockattr_getkind_np\fP() は常に成功する。 エラーの場合、 \fBpthread_rwlockattr_setkind_np\fP() は 0 以外のエラー番号を返す。 .SH エラー .TP \fBEINVAL\fP \fIpref\fP にサポート外の値が指定された。 .SH バージョン 関数 \fBpthread_rwlockattr_getkind_np\fP() と \fBpthread_rwlockattr_setkind_np\fP() は glibc 2.1 で初めて登場した。 .SH 準拠 これらの関数は非標準の GNU による拡張である。 そのため、名前に "_np" (non\-portable; 移植性がない) という接尾辞が付いている。 .SH 関連項目 \fBpthreads\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。