1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified by Michael Haardt (michael@moria.de)
26 .\" Modified Sat Jul 24 14:29:17 1993 by Rik Faith (faith@cs.unc.edu)
27 .\" Modified 961203 and 001211 and 010326 by aeb@cwi.nl
28 .\" Modified 001213 by Michael Haardt (michael@moria.de)
29 .\" Modified 13 Jun 02, Michael Kerrisk <mtk.manpages@gmail.com>
30 .\" Added note on nonstandard behavior when SIGCHLD is ignored.
31 .\" Modified 2004-11-16, mtk, Noted that the nonconformance when
32 .\" SIGCHLD is being ignored is fixed in 2.6.9; other minor changes
33 .\" Modified 2004-12-08, mtk, in 2.6 times() return value changed
35 .\" Added notes on nonstandard behavior: Linux allows 'buf' to
36 .\" be NULL, but POSIX.1 doesn't specify this and it's nonportable.
38 .\" Japanese Version Copyright (c) 1996 Satoshi Nozawa
39 .\" all rights reserved.
40 .\" Translated 1996-06-25, Satoshi I. Nozawa <snozawa@env.sci.ibaraki.ac.jp>
41 .\" Modified 1997-12-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
42 .\" Updated 2001-02-16, Kentaro Shirakata <argrath@ub32.org>
43 .\" Updated 2001-04-10, Kentaro Shirakata <argrath@ub32.org>
44 .\" Updated 2001-05-21, Kentaro Shirakata <argrath@ub32.org>
45 .\" Updated 2002-10-21, Kentaro Shirakata <argrath@ub32.org>
46 .\" Updated 2005-02-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
47 .\" Updated 2005-04-20, Kentaro Shirakata <argrath@ub32.org>
48 .\" Updated 2008-02-12, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.77
50 .\" WORD: clock ticks クロック数
52 .TH TIMES 2 2008-06-25 "Linux" "Linux Programmer's Manual"
56 .B #include <sys/times.h>
58 .BI "clock_t times(struct tms *" buf );
61 .\"O stores the current process times in the
75 .\"O .IR <sys/times.h> :
84 clock_t tms_utime; /* user time */
85 clock_t tms_stime; /* system time */
86 clock_t tms_cutime; /* user time of children */
87 clock_t tms_cstime; /* system time of children */
94 .\"O field contains the CPU time spent executing instructions
95 .\"O of the calling process.
97 フィールドは、呼び出したプロセスが命令を実行するのに消費した
101 .\"O field contains the CPU time spent in the system while
102 .\"O executing tasks on behalf of the calling process.
104 フィールドは、呼び出したプロセスのために実行されたタスクで、
108 .\"O field contains the sum of the
112 .\"O values for all waited-for terminated children.
122 .\"O field contains the sum of the
126 .\"O values for all waited-for terminated children.
135 .\"O Times for terminated children (and their descendants)
136 .\"O are added in at the moment
140 .\"O returns their process ID.
141 .\"O In particular, times of grandchildren
142 .\"O that the children did not wait for are never seen.
143 終了する子(及びその子孫)プロセスの時間は
147 がプロセス ID を返した瞬間に加算される。
148 つまり、子がまだ終了を待っていない状態では
151 .\"O All times reported are in clock ticks.
153 .\"O .SH "RETURN VALUE"
157 .\"O returns the number of clock ticks that have elapsed since
158 .\"O an arbitrary point in the past.
159 .\"O The return value may overflow the possible range of type
161 .\"O On error, \fI(clock_t)\ \-1\fP is returned, and
163 .\"O is set appropriately.
165 は過去のある時点から経過したクロック数 (clock tick) を返す。
168 型が取り得る範囲からオーバーフローするかもしれない。
169 エラーの場合、\fI(clock_t)\ \-1\fP が返され、
172 .\" The only possible error is EFAULT.
173 .\"O .SH "CONFORMING TO"
175 SVr4, 4.3BSD, POSIX.1-2001.
178 .\"O The number of clock ticks per second can be obtained using:
181 .\"O sysconf(_SC_CLK_TCK);
186 sysconf(_SC_CLK_TCK);
191 .\"O In POSIX.1-1996 the symbol \fBCLK_TCK\fP (defined in
193 .\"O is mentioned as obsolescent.
194 .\"O It is obsolete now.
195 POSIX.1-1996 では、\fBCLK_TCK\fP シンボル
197 で定義されている) は古いものであると記述されている。
200 .\"O In Linux kernel versions before 2.6.9,
201 .\"O if the disposition of
205 .\"O then the times of terminated children
206 .\"O are automatically included in the
210 .\"O fields, although POSIX.1-2001 says that this should only happen
211 .\"O if the calling process
213 .\"O on its children.
214 .\"O +This nonconformance is rectified in Linux 2.6.9 and later.
215 Linux 2.6.9 より前のバージョンでは、
226 しかし、POSIX.1-2001 では、この動作は呼び出し元が
228 関数群で子プロセスを待った場合にのみ起きるべきだとしている。
229 標準とは異なるこの動作は Linux 2.6.9 以降で修正されている。
230 .\"O .\" See the description of times() in XSH, which says:
231 .\"O .\" The times of a terminated child process are included... when wait()
232 .\"O .\" or waitpid() returns the process ID of this terminated child.
233 .\" See the description of times() in XSH, which says:
234 .\" The times of a terminated child process are included... when wait()
235 .\" or waitpid() returns the process ID of this terminated child.
239 .\"O argument can be specified as NULL, with the result that
241 .\"O just returns a function result.
244 引数に NULL を指定することができ、その場合は
247 .\"O However, POSIX does not specify this behavior, and most
248 .\"O other UNIX implementations require a non-NULL value for
250 しかし、POSIX はこの振る舞いは規定されておらず、
257 .\"O also returns a value of type
259 .\"O but this value is measured in units of
260 .\"O .BR CLOCKS_PER_SEC ,
261 .\"O not the clock ticks used by
268 で使用されるクロック tick 数ではなく、
272 .\"O On Linux, the "arbitrary point in the past" from which the return value of
274 .\"O is measured has varied across kernel versions.
275 .\"O On Linux 2.4 and earlier this point is the moment the system was booted.
276 .\"O Since Linux 2.6, this point is \fI(2^32/HZ) \- 300\fP
277 .\"O (i.e., about 429 million) seconds before system boot time.
278 .\"O This variability across kernel versions (and across UNIX implementations),
279 .\"O combined with the fact that the returned value may overflow the range of
281 .\"O means that a portable application would be wise to avoid using this value.
282 .\"O To measure changes in elapsed time, use
283 .\"O .BR gettimeofday (2)
287 の返り値を計算する起点となる「過去の任意の時点」は、カーネルのバージョン
289 Linux 2.4 以前では、この時点はシステムが起動した瞬間である。
290 Linux 2.6 以降では、この時点はシステム起動時刻の \fI(2^32/HZ) \- 300\fP
292 このようにカーネルバージョン (や UNIX の実装) により異なることと、
295 の範囲をオーバーフローする可能性があるという事実を考慮すると、
296 移植性が必要なアプリケーションではこの値を使うのは避けるのが賢明であろう。
301 .\"O .\" On older systems the number of clock ticks per second is given
302 .\"O .\" by the variable HZ.
303 .\" 古いシステムでは一秒あたりのクロック数は HZ 変数で与えられる。
304 .\"O .SS "Historical"
308 .\"O and the struct members are of type
310 .\"O although they store clock ticks, not seconds since the Epoch.
313 .\"O for the struct members, because it had no type
320 型を使っていたが、紀元からの秒数ではなくクロック数を格納していた。
328 .\"O A limitation of the Linux system call conventions on some architectures
329 .\"O (notably i386) means that on Linux 2.6 there is a small time window
330 .\"O (41 seconds) soon after boot when
332 .\"O can return \-1, falsely indicating that an error occurred.
333 .\"O The same problem can occur when the return value wraps passed
334 .\"O the maximum value that can be stored in
336 いくつかのアーキテクチャ (特に i386) における Linux のシステムコールの慣習の
337 制限により、Linux 2.6 では起動直後は (41秒と) タイムウィンドウが小さく、
339 がエラーが起こったことを示す \-1 を間違って返すことがある。
342 が格納可能な最大値を超過した際にも同じ問題が起こり得る。
343 .\" The problem is that a syscall return of -4095 to -1
344 .\" is interpreted by glibc as an error, and the wrapper converts
345 .\" the return value to -1.
346 .\" http://marc.info/?l=linux-kernel&m=119447727031225&w=2
347 .\" "compat_sys_times() bogus until jiffies >= 0"