OSDN Git Service

Update drafts for LDP 3.67
[linuxjm/LDP_man-pages.git] / draft / man2 / sched_setaffinity.2
index 8ac0006..ce9915e 100644 (file)
@@ -1,8 +1,7 @@
-.\" man2/sched_setaffinity.2 - sched_setaffinity and sched_getaffinity man page
-.\"
 .\" Copyright (C) 2002 Robert Love
 .\" and Copyright (C) 2006 Michael Kerrisk
 .\"
+.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
 .\" This is free documentation; you can redistribute it and/or
 .\" modify it under the terms of the GNU General Public License as
 .\" published by the Free Software Foundation; either version 2 of
@@ -19,9 +18,9 @@
 .\" GNU General Public License for more details.
 .\"
 .\" You should have received a copy of the GNU General Public
-.\" License along with this manual; if not, write to the Free
-.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
-.\" USA.
+.\" License along with this manual; if not, see
+.\" <http://www.gnu.org/licenses/>.
+.\" %%%LICENSE_END
 .\"
 .\" 2002-11-19 Robert Love <rml@tech9.net> - initial version
 .\" 2004-04-20 mtk - fixed description of return value
 .\" 2008-11-12, mtk, removed CPU_*() macro descriptions to a
 .\" separate CPU_SET(3) page.
 .\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
 .\" Japanese Version Copyright (c) 2003, 2005 Yuichi SATO
 .\"         all rights reserved.
 .\" Translated 2003-01-23, Yuichi SATO <ysato444@yahoo.co.jp>
 .\" Updated & Modified 2006-07-14, Akihiro MOTOKI, LDP v2.34
 .\" Updated & Modified 2008-12-24, Akihiro MOTOKI, LDP v3.14
 .\"
-.\"WORD:       affinity                ¿ÆÏÂÅÙ
-.\"WORD:       most significant bit    ºÇ¾å°Ì¥Ó¥Ã¥È
-.\"WORD:       least significant bit   ºÇ²¼°Ì¥Ó¥Ã¥È
-.\"WORD:       capability              ¸¢¸Â
-.\"
-.TH SCHED_SETAFFINITY 2 2010-09-10 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH Ì¾Á°
-.\"O sched_setaffinity, sched_getaffinity \- \
-.\"O set and get a process's CPU affinity mask
-sched_setaffinity, sched_getaffinity \- \
-¥×¥í¥»¥¹¤Î CPU affinity ¥Þ¥¹¥¯¤òÀßÄꡦ¼èÆÀ¤¹¤ë
-.\"O .SH SYNOPSIS
-.SH ½ñ¼°
+.TH SCHED_SETAFFINITY 2 2014\-05\-10 Linux "Linux Programmer's Manual"
+.SH 名前
+sched_setaffinity, sched_getaffinity \- スレッドの CPU affinity マスクを設定・取得する
+.SH 書式
 .nf
-.\"O .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
-.BR "#define _GNU_SOURCE" "             /* feature_test_macros(7) »²¾È */"
-.B #include <sched.h>
+\fB#define _GNU_SOURCE\fP             /* feature_test_macros(7) 参照 */
+\fB#include <sched.h>\fP
 .sp
-.BI "int sched_setaffinity(pid_t " pid ", size_t " cpusetsize ,
-.BI "                      cpu_set_t *" mask );
+\fBint sched_setaffinity(pid_t \fP\fIpid\fP\fB, size_t \fP\fIcpusetsize\fP\fB,\fP
+\fB                      const cpu_set_t *\fP\fImask\fP\fB);\fP
 .sp
-.BI "int sched_getaffinity(pid_t " pid ", size_t " cpusetsize ,
-.BI "                      cpu_set_t *" mask );
+\fBint sched_getaffinity(pid_t \fP\fIpid\fP\fB, size_t \fP\fIcpusetsize\fP\fB,\fP
+\fB                      cpu_set_t *\fP\fImask\fP\fB);\fP
 .fi
-.\"O .SH DESCRIPTION
-.SH ÀâÌÀ
-.\"Osato:
-.\"Osato: Kernel ¥É¥­¥å¥á¥ó¥È IRQ-affinity.txt ¤ÎÌõ¤Ç¤Ï¡¢
-.\"Osato: "affinity" ¤Ï¡Ö¥¢¥Õ¥£¥Ë¥Æ¥£¡×¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢
-.\"Osato: ¤³¤³¤Ë°ì²ó¤À¤±Ìõ¸ì (¿ÆÏÂÅÙ) ¤òÆþ¤ì¤Æ¤ª¤¯¤À¤±¤Ç¡¢
-.\"Osato: ÆäËÌõ¤µ¤Ê¤¤¤³¤È¤Ë¤·¤è¤¦¤È»×¤¤¤Þ¤¹¡£
-.\"Osato:
-.\"O A process's CPU affinity mask determines the set of CPUs on which
-.\"O it is eligible to run.
-.\"O On a multiprocessor system, setting the CPU affinity mask
-.\"O can be used to obtain performance benefits.
-.\"O For example,
-.\"O by dedicating one CPU to a particular process
-.\"O (i.e., setting the affinity mask of that process to specify a single CPU,
-.\"O and setting the affinity mask of all other processes to exclude that CPU),
-.\"O it is possible to ensure maximum execution speed for that process.
-.\"O Restricting a process to run on a single CPU also avoids
-.\"O the performance cost caused by the cache invalidation that occurs
-.\"O when a process ceases to execute on one CPU and then
-.\"O recommences execution on a different CPU.
-¥×¥í¥»¥¹¤Î CPU affinity (¿ÆÏÂÅÙ) ¥Þ¥¹¥¯¤Ï¡¢¤½¤Î¥×¥í¥»¥¹¤¬
-¼Â¹Ô¤òµö²Ä¤µ¤ì¤Æ¤¤¤ë CPU ¤Î½¸¹ç¤ò·èÄꤹ¤ë¡£
-¥Þ¥ë¥Á¥×¥í¥»¥Ã¥µ¡¦¥·¥¹¥Æ¥à¤Ç¤Ï¡¢CPU affinity ¥Þ¥¹¥¯¤òÀßÄꤹ¤ë¤³¤È¤Ç
-À­Ç½¾å¤Î¥á¥ê¥Ã¥È¤òÆÀ¤é¤ì¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
-Î㤨¤Ð¡¢ÆÃÄê¤Î¥×¥í¥»¥¹¤ò°ì¤Ä¤Î CPU ¤Ë³ç¤êÉÕ¤±
-(¤¹¤Ê¤ï¤Á¡¢¤½¤Î¥×¥í¥»¥¹¤Î affinity ¥Þ¥¹¥¯¤ò°ì¤Ä¤Î CPU ¤ËÀßÄꤷ)¡¢
-¾¤ÎÁ´¤Æ¤Î¥×¥í¥»¥¹¤Î affinity ¥Þ¥¹¥¯¤«¤é¤½¤Î CPU ¤ò½ü³°¤¹¤ë¤³¤È¤Ç¡¢
-³Î¼Â¤Ë¤½¤Î¥×¥í¥»¥¹¤Î¼Â¹Ô®ÅÙ¤òºÇÂç¤Ë¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
-¤Þ¤¿¡¢¤¢¤ë¥×¥í¥»¥¹¤Î¼Â¹Ô¤ò°ì¤Ä¤Î CPU ¤Ë¸ÂÄꤹ¤ë¤³¤È¤Ç¡¢
-°ì¤Ä¤Î CPU ¤Ç¤Î¼Â¹Ô¤òÄä»ß¤·¤Æ¤«¤éÊ̤ΠCPU ¤Ç¼Â¹Ô¤òºÆ³«¤¹¤ë¤È¤­¤ËȯÀ¸¤¹¤ë
-¥­¥ã¥Ã¥·¥å̵¸ú²½ (cache invalidation) ¤Ë¤è¤ëÀ­Ç½Ì̤ÎÎô²½¤òÈò¤±¤ë¤³¤È¤â¤Ç¤­¤ë¡£
-
-.\"O A CPU affinity mask is represented by the
-.\"O .I cpu_set_t
-.\"O structure, a "CPU set", pointed to by
-.\"O .IR mask .
-CPU affinity ¥Þ¥¹¥¯¤Ï¡ÖCPU ¤Î½¸¹ç¡×¤òɽ¤¹
-.I cpu_set_t
-¹½Â¤ÂΤÇɽ¸½¤µ¤ì¡¢
-.I cpu_set_t
-¤Ø¤Î¥Ý¥¤¥ó¥¿
-.I mask
-¤Ç»ØÄꤵ¤ì¤ë¡£
-.\"O A set of macros for manipulating CPU sets is described in
-.\"O .BR CPU_SET (3).
-CPU ½¸¹ç¤òÁàºî¤¹¤ë¤¿¤á¤Î¥Þ¥¯¥í·²¤Ë¤Ä¤¤¤Æ¤Ï
-.BR CPU_SET (3)
-¤Çµ­ºÜ¤µ¤ì¤Æ¤¤¤ë¡£
+.SH 説明
+スレッドの CPU affinity (親和度) マスクは、そのスレッドが 実行を許可されている CPU の集合を決定する。
+マルチプロセッサシステムでは、CPU affinity マスクを設定することで 性能上のメリットを得られる可能性がある。 例えば、特定のスレッドを一つの
+CPU に括り付け (すなわち、そのスレッドの affinity マスクを一つの CPU に設定し)、 他の全てのスレッドの affinity
+マスクからその CPU を除外することで、 確実にそのスレッドの実行速度を最大にすることができる。 また、あるスレッドの実行を一つの CPU
+に限定することで、 一つの CPU での実行を停止してから別の CPU で実行を再開するときに発生する キャッシュ無効化 (cache
+invalidation) による性能面の劣化を避けることもできる。
 
-.\"O .BR sched_setaffinity ()
-.\"O sets the CPU affinity mask of the process whose ID is
-.\"O .I pid
-.\"O to the value specified by
-.\"O .IR mask .
-.BR sched_setaffinity ()
-¤Ï¡¢¥×¥í¥»¥¹ID ¤¬
-.I pid
-¤Î¥×¥í¥»¥¹¤Î CPU affinity ¥Þ¥¹¥¯¤ò
-.I mask
-¤Ç»ØÄꤵ¤ì¤¿ÃͤËÀßÄꤹ¤ë¡£
-.\"O If
-.\"O .I pid
-.\"O is zero, then the calling process is used.
-.\"O The argument
-.\"O .I cpusetsize
-.\"O is the length (in bytes) of the data pointed to by
-.\"O .IR mask .
-.I pid
-¤¬ 0 ¤Î¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤¬»È¤ï¤ì¤ë¡£
-.I cpusetsize
-°ú¤­¿ô¤Ë¤Ï
-.I mask
-¤¬»Ø¤¹¥Ç¡¼¥¿¤ÎŤµ (¥Ð¥¤¥Èñ°Ì) ¤Ç¤¢¤ë¡£
-.\"O Normally this argument would be specified as
-.\"O .IR "sizeof(cpu_set_t)" .
-Ä̾ï¤Ï¡¢¤³¤Î°ú¤­¿ô¤Ë¤Ï
-.I "sizeof(cpu_set_t)"
-¤ò»ØÄꤹ¤ì¤Ð¤è¤¤¡£
+CPU affinity マスクは「CPU の集合」を表す \fIcpu_set_t\fP 構造体で表現され、 \fIcpu_set_t\fP へのポインタ
+\fImask\fP で指定される。 CPU 集合を操作するためのマクロ群については \fBCPU_SET\fP(3)  で記載されている。
 
-.\"O If the process specified by
-.\"O .I pid
-.\"O is not currently running on one of the CPUs specified in
-.\"O .IR mask ,
-.\"O then that process is migrated to one of the CPUs specified in
-.\"O .IR mask .
-.I pid
-¤Ç»ØÄꤵ¤ì¤¿¥×¥í¥»¥¹¤¬
-.I mask
-¤Ç»ØÄꤵ¤ì¤¿ CPU ¤Î¤¤¤º¤ì¤«¤Ç¸½ºß¼Â¹Ô¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
-¤½¤Î¥×¥í¥»¥¹¤Ï
-.I mask
-¤Ç»ØÄꤵ¤ì¤¿ CPU ¤Î¤¤¤º¤ì¤«¤Ë°ÜÆ°¤µ¤ì¤ë¡£
+\fBsched_setaffinity\fP()  は、スレッド ID が \fIpid\fP のスレッドの CPU affinity マスクを \fImask\fP
+で指定された値に設定する。 \fIpid\fP が 0 の場合、呼び出し元スレッドが使われる。 \fIcpusetsize\fP 引き数には \fImask\fP
+が指すデータの長さ (バイト単位) である。 通常は、この引き数には \fIsizeof(cpu_set_t)\fP を指定すればよい。
 
-.\"O .BR sched_getaffinity ()
-.\"O writes the affinity mask of the process whose ID is
-.\"O .I pid
-.\"O into the
-.\"O .I cpu_set_t
-.\"O structure pointed to by
-.\"O .IR mask .
-.\"O The
-.\"O .I cpusetsize
-.\"O argument specifies the size (in bytes) of
-.\"O .IR mask .
-.BR sched_getaffinity ()
-¤Ï¡¢
-¥×¥í¥»¥¹ID ¤¬
-.I pid
-¤Î¥×¥í¥»¥¹¤Î affinity ¥Þ¥¹¥¯¤ò
-.I mask
-¤¬»Ø¤¹
-.I cpu_set_t
-¹½Â¤ÂΤ˽ñ¤­¹þ¤à¡£
-.I cpusetsize
-°ú¤­¿ô¤Ë¤Ï
-.I mask
-¤Î (¥Ð¥¤¥Èñ°Ì¤Î) Â礭¤µ¤ò»ØÄꤹ¤ë¡£
+\fIpid\fP で指定されたスレッドが \fImask\fP で指定された CPU のいずれかで現在実行されていない場合、 そのスレッドは \fImask\fP
+で指定された CPU のいずれかに移動される。
 
-´Ø¿ô
-.BR sched_getaffinity ()
-¤ÏŤµ
-.I len
-¤Î¥Ý¥¤¥ó¥¿
-.I mask
-¤Ë¥×¥í¥»¥¹
-.I pid
-¤Î affinity ¥Þ¥¹¥¯¤ò½ñ¤­¹þ¤à¡£
-.\"O If
-.\"O .I pid
-.\"O is zero, then the mask of the calling process is returned.
-.I pid
-¤¬ 0 ¤Î¾ì¹ç¡¢¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤Î¥Þ¥¹¥¯¤¬ÊÖ¤µ¤ì¤ë¡£
-.\"O .SH "RETURN VALUE"
-.SH ÊÖ¤êÃÍ
-.\"O On success,
-.\"O .BR sched_setaffinity ()
-.\"O and
-.\"O .BR sched_getaffinity ()
-.\"O return 0.
-À®¸ù¤·¤¿¾ì¹ç¡¢
-.BR sched_setaffinity ()
-¤È
-.BR sched_getaffinity ()
-¤Ï 0 ¤òÊÖ¤¹¡£
-.\"O On error, \-1 is returned, and
-.\"O .I errno
-.\"O is set appropriately.
-¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢
-.I errno
-¤òŬÀÚ¤ËÀßÄꤹ¤ë¡£
-.\"O .SH ERRORS
-.SH ¥¨¥é¡¼
-.TP
-.B EFAULT
-.\"O A supplied memory address was invalid.
-»ØÄꤵ¤ì¤¿¥á¥â¥êÈÖÃϤ¬ÉÔÀµ¤Ç¤¢¤ë¡£
-.TP
-.B EINVAL
-.\"O The affinity bit mask
-.\"O .I mask
-.\"O contains no processors that are currently physically on the system
-.\"O and permitted to the process according to any restrictions that
-.\"O may be imposed by the "cpuset" mechanism described in
-.\"O .BR cpuset (7).
-¥·¥¹¥Æ¥à¾å¤Ë¸½ºß¼ÂºÝ¤Ë¸ºß¤·¡¢¤«¤Ä
-"cpuset" µ¡¹½¤¬²Ý¤¹À©¸Â¤Ë¤ª¤¤¤Æ¤½¤Î¥×¥í¥»¥¹¤ËÂФ·¤Æµö²Ä¤µ¤ì¤Æ¤¤¤ë
-¥×¥í¥»¥Ã¥µ¤¬¡¢
-affinity ¥Ó¥Ã¥È¥Þ¥¹¥¯
-.I mask
-¤Ë´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¡£
-"cpuset" µ¡¹½¤Ë¤Ä¤¤¤Æ¤Ï
-.BR cpuset (7)
-¤ò»²¾È¡£
-.TP
-.B EINVAL
-.\"O .RB ( sched_getaffinity ()
-.\"O and, in kernels before 2.6.9,
-.\"O .BR sched_setaffinity ())
-.\"O .I cpusetsize
-.\"O is smaller than the size of the affinity mask used by the kernel.
-.RB ( sched_getaffinity ()
-¤È¡¢¥«¡¼¥Í¥ë 2.6.9 °ÊÁ°¤Î
-.BR sched_setaffinity ())
-.I cpusetsize
-¤¬¥«¡¼¥Í¥ë¤Ç»È¤ï¤ì¤Æ¤¤¤ë affinity ¥Þ¥¹¥¯¤Î¥µ¥¤¥º¤è¤ê¾®¤µ¤¤¡£
-.TP
-.B EPERM
-.\"O .RB ( sched_setaffinity ())
-.\"O The calling process does not have appropriate privileges.
-.\"O The caller needs an effective user ID equal to the user ID
-.\"O or effective user ID of the process identified by
-.\"O .IR pid ,
-.\"O or it must possess the
-.\"O .B CAP_SYS_NICE
-.\"O capability.
-.RB ( sched_setaffinity ())
-¸Æ¤Ó½Ð¤·¸µ¤Î¥×¥í¥»¥¹¤ËŬÀÚ¤ÊÆø¢¤¬¤Ê¤«¤Ã¤¿¡£
-¸Æ¤Ó½Ð¤·¸µ¤Ï¡¢¼Â¸ú¥æ¡¼¥¶ ID ¤¬
-.I pid
-¤Ç¼±Ê̤µ¤ì¤ë¥×¥í¥»¥¹¤Î¥æ¡¼¥¶ ID ¤Þ¤¿¤Ï¼Â¸ú¥æ¡¼¥¶ ID ¤ÈƱ¤¸¤Ç¤¢¤ë¤«¡¢
-.B CAP_SYS_NICE
-¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£ (capability) ¤ò»ý¤¿¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
-.TP
-.B ESRCH
-.\"O The process whose ID is \fIpid\fP could not be found.
-¥×¥í¥»¥¹ ID \fIpid\fP ¤Î¥×¥í¥»¥¹¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¡£
-.\"O .SH VERSIONS
-.SH ¥Ð¡¼¥¸¥ç¥ó
-.\"O The CPU affinity system calls were introduced in Linux kernel 2.5.8.
-CPU affinity ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux kernel 2.5.8 ¤ÇƳÆþ¤µ¤ì¤¿¡£
-.\"O The system call wrappers were introduced in glibc 2.3.
-.\"O Initially, the glibc interfaces included a
-.\"O .I cpusetsize
-.\"O argument, typed as
-.\"O .IR "unsigned int" .
-.\"O In glibc 2.3.3, the
-.\"O .I cpusetsize
-.\"O argument was removed, but was then restored in glibc 2.3.4, with type
-.\"O .IR size_t .
-¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï glibc 2.3 ¤ÇƳÆþ¤µ¤ì¤¿¡£
-ºÇ½é¤Ï¡¢glibc ¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ë¤Ï
-.I "unsigned int"
-·¿¤Î
-.I cpusetsize
-°ú¤­¿ô¤¬Æþ¤Ã¤Æ¤¤¤¿¡£
-glibc 2.3.3 ¤Ç¤Ï
-.I cpusetsize
-°ú¤­¿ô¤¬ºï½ü¤µ¤ì¤¿¤¬¡¢glibc 2.3.4 ¤Ç
-.I size_t
-·¿¤ÇÉü³è¤·¤¿¡£
-.\"O .SH "CONFORMING TO"
-.SH ½àµò
-.\"O These system calls are Linux-specific.
-¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux ¸ÇÍ­¤Ç¤¢¤ë¡£
-.\"O .SH "NOTES"
-.SH Ãí°Õ
-.\"O After a call to
-.\"O .BR sched_setaffinity (),
-.\"O the set of CPUs on which the process will actually run is
-.\"O the intersection of the set specified in the
-.\"O .I mask
-.\"O argument and the set of CPUs actually present on the system.
-.BR sched_setaffinity ()
-¤ò¸Æ¤Ó½Ð¤·¤¿¸å¤Ï¡¢¥×¥í¥»¥¹¤¬¼ÂºÝ¤Ë¼Â¹Ô¤µ¤ì¤ë CPU ¤Î½¸¹ç¤Ï¡¢
-.I mask
-°ú¤­¿ô¤Ç»ØÄꤵ¤ì¤¿½¸¹ç¤È¡¢¥·¥¹¥Æ¥à¾å¤Ë¼ÂºÝ¤Ë¸ºß¤¹¤ë CPU ¤Î½¸¹ç¤Î
-¶¦Ä̽¸¹ç (AND) ¤È¤Ê¤ë¡£
-.\"O The system may further restrict the set of CPUs on which the process
-.\"O runs if the "cpuset" mechanism described in
-.\"O .BR cpuset (7)
-.\"O is being used.
-.\"O These restrictions on the actual set of CPUs on which the process
-.\"O will run are silently imposed by the kernel.
-"cpuset" µ¡¹½¤¬»ÈÍѤµ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢¥×¥í¥»¥¹¤¬Æ°ºî¤¹¤ë CPU ½¸¹ç
-¤ËÂФ·¤Æ¥·¥¹¥Æ¥à¤Ï¤µ¤é¤ËÀ©¸Â¤ò²Ã¤¨¤ë¤«¤â¤·¤ì¤Ê¤¤
-("cpuset" µ¡¹½¤Ë¤Ä¤¤¤Æ¤Ï
-.BR cpuset (7)
-¤ò»²¾È)¡£
-¥×¥í¥»¥¹¤¬Æ°ºî¤¹¤ë¼ÂºÝ¤Î CPU ½¸¹ç¤ËÂФ¹¤ëÀ©¸Â¤Ï¥«¡¼¥Í¥ë¤Ë¤è¤ê
-°ÅÌۤΤ¦¤Á¤ËŬÍѤµ¤ì¤ë¡£
+\fBsched_getaffinity\fP()  は、 スレッド ID が \fIpid\fP のスレッドの affinity マスクを \fImask\fP が指す
+\fIcpu_set_t\fP 構造体に書き込む。 \fIcpusetsize\fP 引き数には \fImask\fP の (バイト単位の) 大きさを指定する。
+.SH 返り値
+成功した場合、 \fBsched_setaffinity\fP()  と \fBsched_getaffinity\fP()  は 0 を返す。 エラーの場合は
+\-1 を返し、 \fIerrno\fP を適切に設定する。
+.SH エラー
+.TP 
+\fBEFAULT\fP
+指定されたメモリ番地が不正である。
+.TP 
+\fBEINVAL\fP
+システム上に現在実際に存在し、かつ "cpuset" 機構が課す制限においてそのスレッドに対して許可されている プロセッサが、 affinity
+ビットマスク \fImask\fP に含まれていない。 "cpuset" 機構については \fBcpuset\fP(7)  を参照。
+.TP 
+\fBEINVAL\fP
+(\fBsched_getaffinity\fP()  と、カーネル 2.6.9 以前の \fBsched_setaffinity\fP())
+\fIcpusetsize\fP がカーネルで使われている affinity マスクのサイズより小さい。
+.TP 
+\fBEPERM\fP
+(\fBsched_setaffinity\fP())  呼び出し元のスレッドに適切な特権がなかった。 呼び出し元は、実効ユーザ ID が \fIpid\fP
+で識別されるスレッドの実ユーザ ID または実効ユーザ ID と同じであるか、 \fBCAP_SYS_NICE\fP ケーパビリティ (capability)
+を持たなければならない。
+.TP 
+\fBESRCH\fP
+ID が \fIpid\fP のスレッドが見つからなかった。
+.SH バージョン
+CPU affinity システムコールは Linux kernel 2.5.8 で導入された。 これらのシステムコールのラッパー関数は glibc
+2.3 で導入された。 最初は、glibc のインタフェースには \fIunsigned int\fP 型の \fIcpusetsize\fP 引き数が入っていた。
+glibc 2.3.3 では \fIcpusetsize\fP 引き数が削除されたが、glibc 2.3.4 で \fIsize_t\fP 型で復活した。
+.SH 準拠
+これらのシステムコールは Linux 固有である。
+.SH 注意
+\fBsched_setaffinity\fP()  を呼び出した後は、スレッドが実際に実行される CPU の集合は、 \fImask\fP
+引き数で指定された集合と、システム上に実際に存在する CPU の集合の 共通集合 (AND) となる。 "cpuset"
+機構が使用されている場合には、スレッドが動作する CPU 集合 に対してシステムはさらに制限を加えるかもしれない ("cpuset" 機構については
+\fBcpuset\fP(7)  を参照)。 スレッドが動作する実際の CPU 集合に対する制限はカーネルにより 暗黙のうちに適用される。
 
-.\"O .BR sched_setscheduler (2)
-.\"O has a description of the Linux scheduling scheme.
-.BR sched_setscheduler (2)
-¤Ë¤Ï Linux ¤Ë¤ª¤±¤ë¥¹¥±¥¸¥å¡¼¥ê¥ó¥°µ¡¹½¤Ë¤Ä¤¤¤Æ¤ÎÀâÌÀ¤¬¤¢¤ë¡£
+\fBsched\fP(7) に Linux のスケジューリング方式についての説明がある。
 .PP
-.\"O The affinity mask is actually a per-thread attribute that can be
-.\"O adjusted independently for each of the threads in a thread group.
-.\"O The value returned from a call to
-.\"O .BR gettid (2)
-.\"O can be passed in the argument
-.\"O .IR pid .
-¼ÂºÝ¤Ë¤Ï affinity ¥Þ¥¹¥¯¤Ï¥¹¥ì¥Ã¥Éñ°Ì¤Î°À­¤Ç¡¢¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î
-³Æ¥¹¥ì¥Ã¥Éñ°Ì¤ËÆÈΩ¤·¤ÆÄ´À°¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
-.BR gettid (2)
-¥³¡¼¥ë¤«¤é¤ÎÊÖ¤êÃͤò¤³¤Î¥³¡¼¥ë¤Î
-.I pid
-°ú¤­¿ô¤È¤·¤ÆÅϤ¹¤³¤È¤¬¤Ç¤­¤ë¡£
-.\"O Specifying
-.\"O .I pid
-.\"O as 0 will set the attribute for the calling thread,
-.\"O and passing the value returned from a call to
-.\"O .BR getpid (2)
-.\"O will set the attribute for the main thread of the thread group.
-.\"O (If you are using the POSIX threads API, then use
-.\"O .BR pthread_setaffinity_np (3)
-.\"O instead of
-.\"O .BR sched_setaffinity ().)
-.I pid
-¤Ë 0 ¤ò»ØÄꤹ¤ë¤È¸Æ¤Ó½Ð¤·¸µ¤Î¥¹¥ì¥Ã¥É¤Î°À­¤¬ÀßÄꤵ¤ì¡¢
-.BR getpid (2)
-¥³¡¼¥ë¤«¤é¤ÎÊÖ¤êÃͤò
-.I pid
-¤Ë»ØÄꤹ¤ë¤È¥¹¥ì¥Ã¥É¥°¥ë¡¼¥×¤Î¥á¥¤¥ó¥¹¥ì¥Ã¥É¤Î°À­¤¬ÀßÄꤵ¤ì¤ë
-(POSIX ¥¹¥ì¥Ã¥É API ¤ò»ÈÍѤ·¤Æ¤¤¤ë¾ì¹ç¡¢
-.BR sched_setaffinity ()
-¤ÎÂå¤ï¤ê¤Ë
-.BR pthread_setaffinity_np (3)
-¤ò»ÈÍѤ¹¤ë¤³¤È)¡£
+affinity マスクはスレッド単位の属性で、スレッドグループの 各スレッド単位に独立して調整することができる。 \fBgettid\fP(2)
+コールからの返り値をこのコールの \fIpid\fP 引き数として渡すことができる。 \fIpid\fP に 0 を指定すると呼び出し元のスレッドの属性が設定され、
+\fBgetpid\fP(2)  コールからの返り値を \fIpid\fP に指定するとスレッドグループのメインスレッドの属性が設定される (POSIX スレッド
+API を使用している場合、 \fBsched_setaffinity\fP()  の代わりに \fBpthread_setaffinity_np\fP(3)
+を使用すること)。
 
-.\"O A child created via
-.\"O .BR fork (2)
-.\"O inherits its parent's CPU affinity mask.
-.\"O The affinity mask is preserved across an
-.\"O .BR execve (2).
-.BR fork (2)
-·Ðͳ¤ÇÀ¸À®¤µ¤ì¤¿»Ò¥×¥í¥»¥¹¤Ï¿Æ¥×¥í¥»¥¹¤Î CPU affinity ¥Þ¥¹¥¯¤ò·Ñ¾µ¤¹¤ë¡£
-affinity ¥Þ¥¹¥¯¤Ï
-.BR execve (2)
-¤ÎÁ°¸å¤ÇÊݸ¤µ¤ì¤ë¡£
+\fBfork\fP(2)  経由で生成された子プロセスは親プロセスの CPU affinity マスクを継承する。 affinity マスクは
+\fBexecve\fP(2)  の前後で保存される。
 
-.\"O This manual page describes the glibc interface for the CPU affinity calls.
-.\"O The actual system call interface is slightly different, with the
-.\"O .I mask
-.\"O being typed as
-.\"O .IR "unsigned long *" ,
-.\"O reflecting the fact that the underlying implementation of CPU
-.\"O sets is a simple bit mask.
-.\"O On success, the raw
-.\"O .BR sched_getaffinity ()
-.\"O system call returns the size (in bytes) of the
-.\"O .I cpumask_t
-.\"O data type that is used internally by the kernel to
-.\"O represent the CPU set bit mask.
-¤³¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Ç¤Ï CPU affinity ¥³¡¼¥ë¤Î glibc ¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤ò
-ÀâÌÀ¤·¤Æ¤¤¤ë¡£¼ÂºÝ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ï¾¯¤·°ã¤Ã¤Æ¤ª¤ê¡¢
-¼ÂºÝ¤Î¼ÂÁõ¤Ç¤Ï CPU ½¸¹ç¤Ï´Êñ¤Ê¥Ó¥Ã¥È¥Þ¥¹¥¯¤Ç¤¢¤ë¤È¤¤¤¦¼Â¾õ¤òÈ¿±Ç¤·¡¢
-.I mask
-¤Î·¿¤¬
-.IR "unsigned long *"
-¤È¤Ê¤Ã¤Æ¤¤¤ë¡£
-À®¸ù»þ¤Ë¤Ï¡¢À¸¤Î
-.BR sched_getaffinity ()
-¥·¥¹¥Æ¥à¥³¡¼¥ë¼«¿È¤Ï
-.I cpumask_t
-¥Ç¡¼¥¿·¿¤Î (¥Ð¥¤¥Èñ°Ì¤Î) Â礭¤µ¤òÊÖ¤¹¡£
-.I cpumask_t
-¤Ï¥«¡¼¥Í¥ëÆâÉô¤Ç CPU ½¸¹ç¤Î¥Ó¥Ã¥È¥Þ¥¹¥¯¤òɽ¸½¤¹¤ë¤Î¤Ë
-»È¤ï¤ì¤Æ¤¤¤ë¥Ç¡¼¥¿·¿¤Ç¤¢¤ë¡£
-.\"O .SH "SEE ALSO"
-.SH ´ØÏ¢¹àÌÜ
-.BR clone (2),
-.BR getcpu (2),
-.BR getpriority (2),
-.BR gettid (2),
-.BR nice (2),
-.BR sched_get_priority_max (2),
-.BR sched_get_priority_min (2),
-.BR sched_getscheduler (2),
-.BR sched_setscheduler (2),
-.BR setpriority (2),
-.BR pthread_setaffinity_np (3),
-.BR CPU_SET (3),
-.BR sched_getcpu (3),
-.BR capabilities (7),
-.BR cpuset (7)
+このマニュアルページでは CPU affinity コールの glibc インタフェースを
+説明している。実際のシステムコールインタフェースは少し違っており、 実際の実装では CPU 集合は簡単なビットマスクであるという実状を反映し、
+\fImask\fP の型が \fIunsigned long\ *\fP となっている。 成功時には、生の \fBsched_getaffinity\fP()
+システムコール自身は \fIcpumask_t\fP データ型の (バイト単位の) 大きさを返す。 \fIcpumask_t\fP はカーネル内部で CPU
+集合のビットマスクを表現するのに 使われているデータ型である。
+.SH 関連項目
+.ad l
+.nh
+\fBtaskset\fP(1), \fBclone\fP(2), \fBgetcpu\fP(2), \fBgetpriority\fP(2), \fBgettid\fP(2),
+\fBnice\fP(2), \fBsched_get_priority_max\fP(2), \fBsched_get_priority_min\fP(2),
+\fBsched_getscheduler\fP(2), \fBsched_setscheduler\fP(2), \fBsetpriority\fP(2),
+\fBCPU_SET\fP(3), \fBpthread_setaffinity_np\fP(3), \fBsched_getcpu\fP(3),
+\fBcapabilities\fP(7), \fBcpuset\fP(7), \fBsched\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。