OSDN Git Service

2f835c5b55c27034c9f4d22c9c377044b1f8eb23
[linuxjm/LDP_man-pages.git] / release / man2 / getcpu.2
1 .\" This man page is Copyright (C) 2006 Andi Kleen <ak@muc.de>.
2 .\"
3 .\" %%%LICENSE_START(VERBATIM_ONE_PARA)
4 .\" Permission is granted to distribute possibly modified copies
5 .\" of this page provided the header is included verbatim,
6 .\" and in case of nontrivial modification author and date
7 .\" of the modification is added to the header.
8 .\" %%%LICENSE_END
9 .\"
10 .\" 2008, mtk, various edits
11 .\"
12 .\"*******************************************************************
13 .\"
14 .\" This file was generated with po4a. Translate the source file.
15 .\"
16 .\"*******************************************************************
17 .\"
18 .\" Japanese Version Copyright (c) 2012  Akihiro MOTOKI
19 .\"         all rights reserved.
20 .\" Translated 2012-05-10, Akihiro MOTOKI <amotoki@gmail.com>
21 .\" Updated 2012-05-29, Akihiro MOTOKI <amotoki@gmail.com>
22 .\" Updated 2013-03-26, Akihiro MOTOKI <amotoki@gmail.com>
23 .\" Updated 2013-05-04, Akihiro MOTOKI <amotoki@gmail.com>
24 .\"
25 .TH GETCPU 2 2013\-04\-03 Linux "Linux Programmer's Manual"
26 .SH 名前
27 getcpu \- 呼び出し元スレッドが動作している CPU と NUMA ノードを判定する
28 .SH 書式
29 .nf
30 \fB#include <linux/getcpu.h>\fP
31 .sp
32 \fBint getcpu(unsigned *\fP\fIcpu\fP\fB, unsigned *\fP\fInode\fP\fB, struct getcpu_cache *\fP\fItcache\fP\fB);\fP
33 .fi
34
35 \fI注\fP: このシステムコールには glibc のラッパー関数は存在しない。「注意」の節を参照。
36 .SH 説明
37 \fBgetcpu\fP() システムコールは、呼び出し元のスレッドやプロセスが
38 現在動作しているプロセッサやノードの情報を特定し、
39 それぞれ引き数 \fIcpu\fP と \fInode\fP が指す整数に書き込む。
40 プロセッサ情報は CPU を識別するための一意な小さな整数である。
41 ノード情報は NUMAノードを識別するための一意な小さな整数である。
42 \fIcpu\fP か \fInode\fP のいずれかが NULL であれば、
43 その引き数に対応する情報の書き込みは行われない。
44
45 このシステムコールの 3 番目の引き数は現在は使われておらず、 Linux 2.6.23 以前への移植性が必要な場合以外は NULL を渡すべきである
46 (「注意」を参照)。
47
48 \fIcpu\fP に格納された情報が最新だと保証できるのは、システムコールが呼ばれ
49 た時点だけである。\fBsched_setaffinity\fP(2) を使って CPU affinity が固定
50 されていない限り、カーネルはいつでも CPU を変更してもよい (スケジューラ
51 はキャッシュが有効に働くように CPU の移動を最小限にしようとするので、
52 通常は CPU が変更されることはないが、起きる可能性はある)。
53 \fIcpu\fP や \fInode\fP で返された情報が呼び出しが返った時点ですでに
54 最新の状況と異なる可能性があり、呼び出し元はこの可能性を考慮して
55 おかなければならない。
56 .SH 返り値
57 成功すると、0 を返す。
58 エラーの場合、\-1 を返し、 \fIerrno\fP にエラーを示す値を設定する。
59 .SH エラー
60 .TP 
61 \fBEFAULT\fP
62 引き数が呼び出したプロセスのアドレス空間外を指している。
63 .SH バージョン
64 \fBgetcpu\fP() はカーネル 2.6.19 で x86_64 と i386 向けに追加された.
65 .SH 準拠
66 \fBgetcpu\fP() は Linux 固有である。
67 .SH 注意
68 Linux はこのシステムコールを可能な限り早く実行しようとする。
69 \fBgetcpu\fP() は、CPU 毎のデータに対する最適化や NUMA 環境での最適化を
70 プログラムが行えるようにすることを目的として実装されているからである。
71
72 glibc はこのシステムコールに対するラッパー関数を提供していない。
73 \fBsyscall\fP(2) を使って呼び出すか、
74 代わりに \fBsched_getcpu\fP(3) を使用すること。
75
76 .\" commit 4307d1e5ada595c87f9a4d16db16ba5edb70dcb1
77 .\" Author: Ingo Molnar <mingo@elte.hu>
78 .\" Date:   Wed Nov 7 18:37:48 2007 +0100
79 .\" x86: ignore the sys_getcpu() tcache parameter
80 .\"
81 .\" ===== Before kernel 2.6.24: =====
82 .\" .I tcache
83 .\" is a pointer to a
84 .\" .IR "struct getcpu_cache"
85 .\" that is used as a cache by
86 .\" .BR getcpu ().
87 .\" The caller should put the cache into a thread-local variable
88 .\" if the process is multithreaded,
89 .\" because the cache cannot be shared between different threads.
90 .\" .I tcache
91 .\" can be NULL.
92 .\" If it is not NULL
93 .\" .BR getcpu ()
94 .\" will use it to speed up operation.
95 .\" The information inside the cache is private to the system call
96 .\" and should not be accessed by the user program.
97 .\" The information placed in the cache can change between kernel releases.
98 .\"
99 .\" When no cache is specified
100 .\" .BR getcpu ()
101 .\" will be slower,
102 .\" but always retrieve the current CPU and node information.
103 .\" With a cache
104 .\" .BR getcpu ()
105 .\" is faster.
106 .\" However, the cached information is updated only once per jiffy (see
107 .\" .BR time (7)).
108 .\" This means that the information could theoretically be out of date,
109 .\" although in practice the scheduler's attempt to maintain
110 .\" soft CPU affinity means that the information is unlikely to change
111 .\" over the course of the caching interval.
112 \fItcache\fP 引き数は Linux 2.6.24 以降では使用されない。以前のバージョン
113 のカーネルでは、この引き数が NULL 以外の場合、この引き数には、呼び出し
114 元が割り当てたスレッド専用の記憶領域 (thread\-local storage) 内のバッファ
115 を指すポインタが指定され、このバッファは \fBgetcpu\fP() 用のキャッシュ機構
116 を提供するために利用されていた。非常に低い確率だが古い情報を返してしま
117 うデメリットはあるものの、このキャッシュを使うことで \fBgetcpu\fP() システ
118 ムコールを高速化できた。このキャッシュ機構はCPU 間でのスレッドの移動時
119 に問題になると考えられ、この引き数は今では無視されるようになっている。
120 .SH 関連項目
121 \fBmbind\fP(2), \fBsched_setaffinity\fP(2), \fBset_mempolicy\fP(2),
122 \fBsched_getcpu\fP(3), \fBcpuset\fP(7)
123 .SH この文書について
124 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部
125 である。プロジェクトの説明とバグ報告に関する情報は
126 http://www.kernel.org/doc/man\-pages/ に書かれている。