OSDN Git Service

(split) LDP: Update the version to 3.53 in PO files
[linuxjm/LDP_man-pages.git] / draft / man2 / getrusage.2
1 .\" Copyright (c) 1992 Drew Eckhardt, March 28, 1992
2 .\" and Copyright (c) 2002 Michael Kerrisk
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" 2004-11-16 -- mtk: the getrlimit.2 page, which formerly included
27 .\" coverage of getrusage(2), has been split, so that the latter is
28 .\" now covered in its own getrusage.2.  For older details of change
29 .\" history, etc., see getrlimit.2
30 .\"
31 .\" Modified 2004-11-16, mtk, Noted that the nonconformance
32 .\"     when SIGCHLD is being ignored is fixed in 2.6.9.
33 .\" 2008-02-22, Sripathi Kodi <sripathik@in.ibm.com>: Document RUSAGE_THREAD
34 .\" 2008-05-25, mtk, clarify RUSAGE_CHILDREN + other clean-ups.
35 .\" 2010-05-24, Mark Hills <mark@pogo.org.uk>: Description of fields,
36 .\"     document ru_maxrss
37 .\" 2010-05-24, mtk, enhanced description of various fields
38 .\"
39 .\"*******************************************************************
40 .\"
41 .\" This file was generated with po4a. Translate the source file.
42 .\"
43 .\"*******************************************************************
44 .TH GETRUSAGE 2 2010\-09\-26 Linux "Linux Programmer's Manual"
45 .SH 名前
46 getrusage \- 資源の使用量を取得する
47 .SH 書式
48 \fB#include <sys/time.h>\fP
49 .br
50 \fB#include <sys/resource.h>\fP
51 .sp
52 \fBint getrusage(int \fP\fIwho\fP\fB, struct rusage *\fP\fIusage\fP\fB);\fP
53 .SH 説明
54 .PP
55 \fBgetrusage\fP()  は \fIwho\fP の資源 (resource) の使用量を返す。 \fIwho\fP には以下のいずれか一つを指定できる。
56 .TP 
57 \fBRUSAGE_SELF\fP
58 呼び出したプロセスの資源使用量、 そのプロセス内の全スレッドが使用している資源の合計を返す。
59 .TP 
60 \fBRUSAGE_CHILDREN\fP
61 呼び出したプロセスの子プロセスのうち、 終了して待ち状態にある全プロセスが使用している資源使用量の統計を返す。
62 これらの統計情報には、孫プロセスやその子孫のプロセスのうち、 削除待ちのものが使用している資源も含まれる。
63 .TP 
64 \fBRUSAGE_THREAD\fP (Linux 2.6.26 以降)
65 呼び出したスレッドに関する資源使用量の統計を返す。
66 .PP
67 資源使用量は \fIusage\fP が指す構造体に格納されて返される。 構造体は以下の形式である。
68 .PP
69 .in +4n
70 .nf
71 struct rusage {
72     struct timeval ru_utime; /* 使用されたユーザー CPU 時間 */
73     struct timeval ru_stime; /* 使用されたシステム CPU 時間 */
74     long   ru_maxrss;        /* RAM 上に存在する仮想ページのサイズ
75                                (resident set size) の最大値 */
76     long   ru_ixrss;         /* 共有メモリの合計サイズ */
77     long   ru_idrss;         /* 非共有データの合計サイズ */
78     long   ru_isrss;         /* 非共有スタックの合計サイズ */
79     long   ru_minflt;        /* ページの再利用 (ソフトページフォルト) */
80     long   ru_majflt;        /* ページフォールト (ハードページフォルト) */
81     long   ru_nswap;         /* スワップ */
82     long   ru_inblock;       /* ブロック入力操作 */
83     long   ru_oublock;       /* ブロック出力操作 */
84     long   ru_msgsnd;        /* 送信された IPC メッセージ */
85     long   ru_msgrcv;        /* 受信された IPC メッセージ */
86     long   ru_nsignals;      /* 受信されたシグナル */
87     long   ru_nvcsw;         /* 意図したコンテキスト切り替え */
88     long   ru_nivcsw;        /* 意図しないコンテキスト切り替え */
89 };
90 .fi
91 .in
92 .PP
93 すべてのフィールドがサポートされているわけではない。 メンテナンスされていないフィールドには、 カーネルが 0 を設定する
94 (メンテナンスされていないフィールドは、 他のシステムとの互換性のために提供されており、 いつか Linux でもサポートされるかもしれない)。
95 各フィールドの詳細は以下の通りである。
96 .TP 
97 \fIru_utime\fP
98 ユーザモードでの実行で消費された合計時間。 \fItimeval\fP 構造体 (秒とミリ秒) で表現される。
99 .TP 
100 \fIru_stime\fP
101 カーネルモードでの実行で消費された合計時間。 \fItimeval\fP 構造体 (秒とミリ秒) で表現される。
102 .TP 
103 \fIru_maxrss\fP (Linux 2.6.32 以降)
104 使用された resident set size の最大値 (キロバイト単位)。 \fBRUSAGE_CHILDREN\fP の場合には、プロセスツリーの
105 resident set size の最大値ではなく、 最も大きい子プロセスの resident set size となる。
106 .TP 
107 \fIru_ixrss\fP (メンテナンスされていない)
108 .\" On some systems,
109 .\" this is the integral of the text segment memory consumption,
110 .\" expressed in kilobyte-seconds.
111 このフィールドは現在のところ Linux では未使用である。
112 .TP 
113 \fIru_idrss\fP (メンテナンスされていない)
114 .\" On some systems, this is the integral of the data segment memory consumption,
115 .\" expressed in kilobyte-seconds.
116 このフィールドは現在のところ Linux では未使用である。
117 .TP 
118 \fIru_isrss\fP (メンテナンスされていない)
119 .\" On some systems, this is the integral of the stack memory consumption,
120 .\" expressed in kilobyte-seconds.
121 このフィールドは現在のところ Linux では未使用である。
122 .TP 
123 \fIru_minflt\fP
124 I/O 動作なしで発生したページフォルトの回数。 再割り当てを待っているページリストからページフレームを「回収」 (reclaim) することで、
125 I/O 動作を避けることができる。
126 .TP 
127 \fIru_majflt\fP
128 I/O 動作を必要とするページフォルトの回数。
129 .TP 
130 \fIru_nswap\fP (メンテナンスされていない)
131 .\" On some systems, this is the number of swaps out of physical memory.
132 このフィールドは現在のところ Linux では未使用である。
133 .TP 
134 \fIru_inblock\fP (Linux 2.6.22 以降)
135 ファイルシステムが入力を実行する必要があった回数。
136 .TP 
137 \fIru_oublock\fP (Linux 2.6.22 以降)
138 ファイルシステムが出力を実行する必要があった回数。
139 .TP 
140 \fIru_msgsnd\fP (メンテナンスされていない)
141 .\" On FreeBSD 6.2, this appears to measure messages sent over sockets
142 .\" On some systems,
143 .\" this field records the number of messages sent over sockets.
144 このフィールドは現在のところ Linux では未使用である。
145 .TP 
146 \fIru_msgrcv\fP (メンテナンスされていない)
147 .\" On FreeBSD 6.2, this appears to measure messages received over sockets
148 .\" On some systems,
149 .\" this field records the number of messages received over sockets.
150 このフィールドは現在のところ Linux では未使用である。
151 .TP 
152 \fIru_nsignals\fP (メンテナンスされていない)
153 .\" On some systems, this field records the number of signals received.
154 このフィールドは現在のところ Linux では未使用である。
155 .TP 
156 \fIru_nvcsw\fP (Linux 2.6 以降)
157 自分のタイムスライスが完了する前にプロセスが自発的にプロセッサを解放して行われたコンテキストスイッチの回数
158 (通常はリソースが利用可能になるのを待つために行われる)。
159 .TP 
160 \fImemory_migrate\fP (Linux 2.6.16 以降)
161 優先度が自分より高いプロセッサが実行可能になったか、現在のプロセスが自分のタイムスライスを超過したことにより行われたコンテキストスイッチの回数。
162 .PP
163 .SH 返り値
164 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
165 .SH エラー
166 .TP 
167 \fBEFAULT\fP
168 \fIusage\fP がアクセス可能なアドレス空間の外を指している。
169 .TP 
170 \fBEINVAL\fP
171 \fIwho\fP が無効である。
172 .SH 準拠
173 SVr4, 4.3BSD.  POSIX.1\-2001 は \fBgetrusage\fP()  を規定しているが、規定しているフィールドは
174 \fIru_utime\fP と \fIru_stime\fP だけである。
175
176 \fBRUSAGE_THREAD\fP は Linux 固有である。
177 .SH 注意
178 \fBexecve\fP(2)  の前後でリソース使用量の指標は保持される。
179
180 今日では \fI<sys/time.h>\fP をインクルードする必要はないが、 インクルードしておけば移植性が増す。 (実際
181 \fIstruct timeval\fP は \fI<sys/time.h>\fP で定義されている。)
182 .PP
183 .\" See the description of getrusage() in XSH.
184 .\" A similar statement was also in SUSv2.
185 2.6.9 より前のバージョンの Linux カーネルでは、 \fBSIGCHLD\fP の処理が \fBSIG_IGN\fP に設定されていると、
186 子プロセスのリソース使用量が \fBRUSAGE_CHILDREN\fP で返される値に自動的に含められる。 しかし POSIX.1\-2001
187 では、これを明確に禁止している。 この準拠していなかった点は、Linux 2.6.9 以降で改正された。
188 .LP
189 このページの最初で示した構造体の定義は 4.3BSD Reno のものである。
190
191 古いシステムでは、 \fBgetrusage\fP() と同様の目的を持つ関数 \fBvtimes\fP() が提供
192 されていた。後方互換性のため、glibc でも \fBvtimes\fP() を提供している。
193 全ての新しいアプリケーションでは \fBgetrusage\fP() を使用すべきである。
194
195 \fBproc\fP(5)  にある \fI/proc/PID/stat\fP の説明も参照のこと。
196 .SH 関連項目
197 \fBclock_gettime\fP(2), \fBgetrlimit\fP(2), \fBtimes\fP(2), \fBwait\fP(2), \fBwait4\fP(2),
198 \fBclock\fP(3)
199 .SH この文書について
200 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.53 の一部
201 である。プロジェクトの説明とバグ報告に関する情報は
202 http://www.kernel.org/doc/man\-pages/ に書かれている。