.\"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 verbat`im 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 2014\-10\-15 "Linux Programmer's Manual" .SH 名前 pthread_rwlockattr_setkind_np, pthread_rwlockattr_getkind_np \- スレッドの読み書きロック属性オブジェクトの読み書きロック種別の設定、取得を行う .SH 書式 .nf \fB#include \fP \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 .sp \fI\-pthread\fP でコンパイルしてリンクする。 .sp .fi .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \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 これは \fBPTHREAD_RWLOCK_PREFER_READER_NP\fP の書き込みロック版である。 ただし「バグ」を参照のこと。 .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 バグ .\" http://sourceware.org/bugzilla/show_bug.cgi?id=7057 読み書きロック種別の値を \fBPTHREAD_RWLOCK_PREFER_WRITER_NP\fP に設定することは、 値を \fBPTHREAD_RWLOCK_PREFER_READER_NP\fP に設定するのと同じ動作となる。 読み出しスレッドがロックを保持する限り、書き込みロックを保持しているスレッドは停止することになる。 ロック種別を \fBPTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\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 プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。