.\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk .\" .\" .\" %%%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. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2012 Akihiro MOTOKI .\" all rights reserved. .\" Translated 2012-05-04, Akihiro MOTOKI .\" Updated 2013-07-17, Akihiro MOTOKI .\" Updated 2013-07-31, Akihiro MOTOKI .\" .TH PTHREAD_ATTR_SETSCOPE 3 2014\-05\-28 Linux "Linux Programmer's Manual" .SH 名前 pthread_attr_setscope, pthread_attr_getscope \- スレッド属性オブジェクトの contention scope 属性の設定/取得を行う .SH 書式 .nf \fB#include \fP \fBint pthread_attr_setscope(pthread_attr_t *\fP\fIattr\fP\fB, int \fP\fIscope\fP\fB);\fP \fBint pthread_attr_getscope(const pthread_attr_t *\fP\fIattr\fP\fB, int *\fP\fIscope\fP\fB);\fP .sp \fI\-pthread\fP でコンパイルしてリンクする。 .fi .SH 説明 \fBpthread_attr_setscope\fP() 関数は、 \fIattr\fP が参照するスレッド属性オブジェクトの contention scope 属性を \fIscope\fP で指定された値に設定する。 contention scope 属性により、 スレッドが CPU などのリソースを取り合うスレッド集合が規定される。 POSIX.1\-2001 では \fIscope\fP に指定する値として 2 つの値が規定されている。 .TP \fBPTHREAD_SCOPE_SYSTEM\fP スレッドは、同じスケジューリング割り当てドメイン (一つ以上のプロセッサ のグループ) にある、システム上の全てのプロセスの自分以外の全ての スレッドとリソースを取り合う。 \fBPTHREAD_SCOPE_SYSTEM\fP のスレッドは、スケジューリングポリシーと 優先度に基づき、互いに相対的にスケジューリングされる。 .TP \fBPTHREAD_SCOPE_PROCESS\fP スレッドは、contention scope が \fBPTHREAD_SCOPE_PROCESS\fP で作成された 同じプロセスの自分以外の全てのスレッドとリソースを取り合う。 \fBPTHREAD_SCOPE_PROCESS\fP のスレッドは、スケジューリングポリシーと優先度 に基づき、同じプロセスの他のスレッドと相対的にスケジューリングされる。 POSIX.1\-2001 では、これらのスレッドがシステム上の他のプロセスのスレッド や同じプロセス内の contention scope が \fBPTHREAD_SCOPE_SYSTEM\fP で作成 された他のスレッドとどのようにリソースを取り合うかは、 規定されないままになっている。 .PP POSIX.1\-2001 で求められているのは、スレッド実装がこれらの contention scope のうち少なくとも 1 つをサポートすることだけである。 Linux は \fBPTHREAD_SCOPE_SYSTEM\fP をサポートしているが、 \fBPTHREAD_SCOPE_PROCESS\fP はサポートしていない。 複数の contention scope をサポートしているシステムで、 \fBpthread_create\fP(3) を呼び出した際に \fBpthread_attr_setscope\fP() で行ったパラメーター設定を有効にするには、 呼び出し側で \fBpthread_attr_setinheritsched\fP(3) を使って 属性オブジェクト \fIattr\fP の inherit\-scheduler 属性を \fBPTHREAD_EXPLICIT_SCHED\fP に設定しておかなければならない。 \fBpthread_attr_getscope\fP() は、 スレッド属性オブジェクト \fIattr\fP の contention scope 属性を \fIscope\fP が指すバッファーに入れて返す。 .SH 返り値 成功すると、これらの関数は 0 を返す。 エラーの場合、0 以外のエラー番号を返す。 .SH エラー \fBpthread_attr_setscope\fP() は以下のエラーで失敗する場合がある。 .TP \fBEINVAL\fP \fIscope\fP に無効な値が指定された。 .TP \fBENOTSUP\fP \fIscope\fP に値 \fBPTHREAD_SCOPE_PROCESS\fP が指定された。 この値は Linux でサポートされていない。 .SH 属性 .SS "マルチスレッディング (pthreads(7) 参照)" 関数 \fBpthread_attr_setscope\fP() と \fBpthread_attr_getscope\fP() はスレッドセーフである。 .SH 準拠 POSIX.1\-2001. .SH 注意 \fBPTHREAD_SCOPE_SYSTEM\fP contention scope では、通常は、一つの ユーザー空間スレッドは一つのカーネルスケジューリングエンティティに 直接結び付けられる。 Linux では、廃止予定の LinuxThreads 実装も新しい NPTL 実装もこれに 該当し、両方とも 1:1 で結び付けられるスレッド実装となっている。 POSIX.1\-2001 では、 contention scope 属性のデフォルト値は 実装時で定義されるものと規定されている。 .SH 関連項目 .ad l .nh \fBpthread_attr_init\fP(3), \fBpthread_attr_setaffinity_np\fP(3), \fBpthread_attr_setinheritsched\fP(3), \fBpthread_attr_setschedparam\fP(3), \fBpthread_attr_setschedpolicy\fP(3), \fBpthread_create\fP(3), \fBpthreads\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。