.\" 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-03, Akihiro MOTOKI .\" .TH PTHREAD_ATTR_SETAFFINITY_NP 3 2014\-05\-28 Linux "Linux Programmer's Manual" .SH 名前 pthread_attr_setaffinity_np, pthread_attr_getaffinity_np \- スレッド属性オブジェクトの CPU affinity 属性の設定/取得を行う .SH 書式 .nf \fB#define _GNU_SOURCE\fP /* See feature_test_macros(7) */ \fB#include \fP \fBint pthread_attr_setaffinity_np(pthread_attr_t *\fP\fIattr\fP\fB,\fP \fB size_t \fP\fIcpusetsize\fP\fB, const cpu_set_t *\fP\fIcpuset\fP\fB);\fP \fBint pthread_attr_getaffinity_np(const pthread_attr_t *\fP\fIattr\fP\fB,\fP \fB size_t \fP\fIcpusetsize\fP\fB, cpu_set_t *\fP\fIcpuset\fP\fB);\fP .sp \fI\-pthread\fP でコンパイルしてリンクする。 .fi .SH 説明 \fBpthread_attr_setaffinity_np\fP() 関数は、 \fIattr\fP が参照するスレッド属性オブジェクトの CPU affinity マスク属性を \fIcpuset\fP で指定された値に設定する。 この属性により、スレッド属性オブジェクト \fIattr\fP を使って 作成されたスレッドの CPU affinity マスクが決定される。 \fBpthread_attr_getaffinity_np\fP() 関数は、 \fIattr\fP が参照する スレッド属性オブジェクトの CPU affinity マスク属性を \fIcpuset\fP が指すバッファーに入れて返す。 \fIcpusetsize\fP 引き数は \fIcpuset\fP が指すバッファーの (バイト単位の) 大きさである。通常は、この引き数には \fIsizeof(cpu_set_t)\fP を 指定することだろう。 CPU affinity マスクの詳細については、 \fBsched_setaffinity\fP(2) を参照してほしい。 CPU 集合の操作や取得を行う際に利用できるマクロ群の説明は \fBCPU_SET\fP(3) を参照してほしい。 .SH 返り値 成功すると、これらの関数は 0 を返す。 エラーの場合、0 以外のエラー番号を返す。 .SH エラー .TP \fBEINVAL\fP .\" cpumask_t .\" The raw sched_getaffinity() system call returns the size (in bytes) .\" of the cpumask_t type. (\fBpthread_attr_setaffinity_np\fP()) \fIcpuset\fP がカーネルがサポートする CPU 集合にない CPU を指定していた。 (CPU 集合を表現するのに使われるカーネルのデータ型がサポートする集合の範囲は、 カーネルの設定オプション \fBCONFIG_NR_CPUS\fP により定義される)。 .TP \fBEINVAL\fP (\fBpthread_attr_getaffinity_np\fP()) \fIattr\fP が参照するスレッド属性オブジェクトの affinity マスク内の CPU が、 \fIcpusetsize\fP により指定された範囲の中になかった (すなわち、\fIcpuset\fP/\fIcpusetsize\fP が小さすぎる)。 .TP \fBENOMEM\fP (\fBpthread_attr_setaffinity_np\fP()) メモリーを割り当てることができなかった。 .SH バージョン これらの関数は glibc バージョン 2.3.4 以降で提供されている。 .SH 準拠 これらの関数は非標準の GNU による拡張である。 そのため、名前に "_np" (nonportable; 移植性がない) という接尾辞が 付いている。 .SH 注意 (このバージョンだけであるが) glibc 2.3.3 では、 これらの関数は \fIcpusetsize\fP 引き数を持っていなかった。 内部で呼ばれるシステムコールに渡される CPU セットの大きさは 常に \fIsizeof(cpu_set_t)\fP であった。 .SH 関連項目 \fBsched_setaffinity\fP(2), \fBpthread_attr_init\fP(3), \fBpthread_setaffinity_np\fP(3), \fBcpuset\fP(7), \fBpthreads\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。