OSDN Git Service

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