1 .\" Copyright (c) 2006 by Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" 2008-06-24, mtk: added some details about where jiffies come into
24 .\" play; added section on high-resolution timers.
26 .\" Japanese Version Copyright (c) 2006 Yuichi SATO
27 .\" all rights reserved.
28 .\" Translated 2006-07-23 by Yuichi SATO <ysato444@yahoo.co.jp>, LDP v2.36
29 .\" Updated 2007-05-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.44
30 .\" Updated 2008-08-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
32 .TH TIME 7 2010-02-25 "Linux" "Linux Programmer's Manual"
35 .\"O time \- overview of time and timers
39 .\"O .SS "Real time and process time"
40 .SS "実時間 (real time) とプロセス時間"
42 .\"O is defined as time measured from some fixed point,
43 .\"O either from a standard point in the past
44 .\"O (see the description of the Epoch and calendar time below),
45 .\"O or from some point (e.g., the start) in the life of a process
46 .\"O .RI ( "elapsed time" ).
47 \fI実時間\fRは、特定の時点から計った時間と定義される。
49 (下記の紀元 (Epoch) とカレンダ時刻の説明を参照) や、
50 プロセスの一生における何らかの時点 (例えば、開始時) である
53 .\"O .I "Process time"
54 .\"O is defined as the amount of CPU time used by a process.
55 .\"O This is sometimes divided into
60 \fIプロセス時間\fRは、プロセスによって使われた総 CPU 時間と定義される。
61 多くの場合、\fIユーザ\fR時間と\fIシステム\fR時間に分けられる。
62 .\"O User CPU time is the time spent executing code in user mode.
63 .\"O System CPU time is the time spent by the kernel executing
64 .\"O in system mode on behalf of the process (e.g., executing system calls).
65 ユーザ CPU 時間は、コードをユーザモードで実行するのに使った時間である。
66 システム CPU 時間は、そのプロセスのために
67 カーネルがシステムモードで実行するのに使った時間である
68 (例えば、システムコールを実行するのに使った時間)。
71 .\"O command can be used to determine the amount of CPU time consumed
72 .\"O during the execution of a program.
74 コマンドはプログラムの実行に費された総 CPU 時間を計るのに使用される。
75 .\"O A program can determine the amount of CPU time it has consumed using
77 .\"O .BR getrusage (2),
80 プログラムは、自身が費した総 CPU 時間を
85 .\"O .SS "The Hardware Clock"
87 .\"O Most computers have a (battery-powered) hardware clock which the kernel
88 .\"O reads at boot time in order to initialize the software clock.
89 多くのコンピュータが (電池で駆動される) ハードウェアクロックを持っている。
90 カーネルは起動時にソフトウェアクロックを初期化するために
92 .\"O For further details, see
101 .\"O .SS "The Software Clock, HZ, and Jiffies"
102 .\"Osato: 以下では jiffies は単数形 jiffy に統一している。
103 .SS "ソフトウェアクロック, HZ, Jiffy"
104 .\"O The accuracy of various system calls that set timeouts,
107 .\"O .BR sigtimedwait (2))
108 .\"O .\" semtimedop(), mq_timedwait(), io_getevents(), poll() are the same
109 .\"O .\" futexes and thus sem_timedwait() seem to use high-res timers.
110 .\"O and measure CPU time (e.g.,
111 .\"O .BR getrusage (2))
112 .\"O is limited by the resolution of the
113 .\"O .IR "software clock" ,
114 .\"O a clock maintained by the kernel which measures time in
116 .\"O The size of a jiffy is determined by the value of the kernel constant
120 .BR sigtimedwait (2))、
121 .\" semtimedop(), mq_timedwait(), io_getevents(), poll() は同じ futex であり、
122 .\" したがっって sem_timedwait() は高精度タイマを使用しているようである。
124 .BR getrusage (2)) する様々なシステムコールの精度は
126 の分解能 (resolution) に制限される。
127 ソフトウェアクロックとは、カーネルが管理する
129 単位で時間を計測するクロックのことである。
136 .\"O varies across kernel versions and hardware platforms.
138 の値はカーネルのバージョンとハードウェアプラットフォームで異なる。
139 .\"O On i386 the situation is as follows:
140 .\"O on kernels up to and including 2.4.x, HZ was 100,
141 .\"O giving a jiffy value of 0.01 seconds;
142 .\"O starting with 2.6.0, HZ was raised to 1000, giving a jiffy of
144 .\"O Since kernel 2.6.13, the HZ value is a kernel
145 .\"O configuration parameter and can be 100, 250 (the default) or 1000,
146 .\"O yielding a jiffies value of, respectively, 0.01, 0.004, or 0.001 seconds.
148 2.4.x とそれより前のカーネルでは、HZ は 100 であったので、
149 jiffy の値は 0.01 秒になっていた。
150 2.6.0 以降では、HZ は 1000 に増やされたので、jiffy の値は 0.001 秒である。
151 カーネル 2.6.13 以降では、HZ の値はカーネル設定パラメータになり、
152 100, 250 (デフォルト), 1000 という値にできる。
153 それぞれ jiffy の値は 0.01, 0.004, 0.001 秒になる。
154 .\"O Since kernel 2.6.20, a further frequency is available:
155 .\"O 300, a number that divides evenly for the common video
156 .\"O frame rates (PAL, 25 HZ; NTSC, 30 HZ).
157 カーネル 2.6.20 以降では、300 も利用できるようになっている。
158 300 は一般的な映像フレームレートの公倍数である (PAL, 25HZ; NTSC, 30HZ)。
162 .\"O system call is a special case.
163 .\"O It reports times with a granularity defined by the kernel constant
165 .\"O Userspace applications can determine the value of this constant using
166 .\"O .IR sysconf(_SC_CLK_TCK) .
173 .I sysconf(_SC_CLK_TCK)
175 .\" glibc gets this info with a little help from the ELF loader;
176 .\" see glibc elf/dl-support.c and kernel fs/binfmt_elf.c.
178 .\"O .SS "High-Resolution Timers"
180 .\"O Before Linux 2.6.21, the accuracy of timer and sleep system calls
181 .\"O (see below) was also limited by the size of the jiffy.
182 Linux 2.6.21 より前では、タイマやスリープ関連のシステムコールの精度も
183 jiffy のサイズにより制限されていた。
185 .\"O Since Linux 2.6.21, Linux supports high-resolution timers (HRTs),
186 .\"O optionally configurable via
187 .\"O .BR CONFIG_HIGH_RES_TIMERS .
188 .\"O On a system that supports HRTs, the accuracy of sleep and timer
189 .\"O system calls is no longer constrained by the jiffy,
190 .\"O but instead can be as accurate as the hardware allows
191 .\"O (microsecond accuracy is typical of modern hardware).
192 .\"O You can determine whether high-resolution timers are supported by
193 .\"O checking the resolution returned by a call to
194 .\"O .BR clock_getres (2)
195 .\"O or looking at the "resolution" entries in
196 .\"O .IR /proc/timer_list .
197 Linux 2.6.21 以降では、Linux は高精度タイマ (high-resolution timers; HRTs)
199 .B CONFIG_HIGH_RES_TIMERS
201 高精度タイマをサポートしているシステムでは、タイマとスリープ関連のシステムコール
202 の精度はもはや jiffy に制約されることはなく、
204 (最近のハードウェアではマイクロ秒単位の精度が一般的である)。
209 内の "resolution" エントリを参照するかで判断できる。
211 .\"O HRTs are not supported on all hardware architectures.
212 .\"O (Support is provided on x86, arm, and powerpc, among others.)
213 高精度タイマはすべてのハードウェアアーキテクチャでサポートされている
214 訳ではない (対応しているアーキテクチャは x86, arm, powerpc である)。
217 .\"O UNIX systems represent time in seconds since the
219 .\"O 1970-01-01 00:00:00 +0000 (UTC).
221 紀元 (1970-01-01 00:00:00 +0000 (UTC)) からの秒数で表現する。
223 .\"O A program can determine the
224 .\"O .I "calendar time"
226 .\"O .BR gettimeofday (2),
227 .\"O which returns time (in seconds and microseconds) that have
228 .\"O elapsed since the Epoch;
229 プログラムは \fIカレンダ時刻\fR を
232 この関数は紀元からの経過時間を (秒とマイクロ秒で) 返す。
234 .\"O provides similar information, but only with accuracy to the
236 .\"O The system time can be changed using
237 .\"O .BR settimeofday (2).
239 は同様の情報を提供するが、最も近い秒の精度しかない。
243 .\"O .SS "Broken-down time"
245 .\"O Certain library functions use a structure of
249 .\"O .IR "broken-down time" ,
250 .\"O which stores time value separated out into distinct components
251 .\"O (year, month, day, hour, minute, second, etc.).
255 この構造体は\fI要素別の時刻\fRを表し、
256 時刻の値を別々の要素 (年・月・日・時・分・秒など) に分けて格納する。
257 .\"O This structure is described in
259 .\"O which also describes functions that convert between calendar time and
260 .\"O broken-down time.
263 に記述されており、カレンダ時刻を要素別の時刻に変換する
265 .\"O Functions for converting between broken-down time and printable
266 .\"O string representations of the time are described in
268 .\"O .BR strftime (3),
270 .\"O .BR strptime (3).
271 要素別の時刻を表示可能な文字列に変換する関数については、
276 .\"O .SS "Sleeping and Setting Timers"
278 .\"O Various system calls and functions allow a program to sleep
279 .\"O (suspend execution) for a specified period of time; see
280 .\"O .BR nanosleep (2),
281 .\"O .BR clock_nanosleep (2),
284 様々なシステムコールと関数により、指定された一定の時間、
285 プログラムはスリープ (実行を停止) することが可能である。
287 .BR clock_nanosleep (2),
291 .\"O Various system calls allow a process to set a timer that expires
292 .\"O at some point in the future, and optionally at repeated intervals;
295 .\"O .BR getitimer (2),
296 .\"O .BR timerfd_create (2),
298 .\"O .BR timer_create (2).
299 様々なシステムコールにより、プロセスは将来のある時点で
301 またオプションとして繰り返し間隔が指定できるものもある。
304 .BR timerfd_create (2),
313 .BR clock_gettime (2),
314 .BR clock_nanosleep (2),
318 .BR gettimeofday (2),
322 .BR timer_create (2),
323 .BR timerfd_create (2),
328 .BR clock_getcpuclockid (3),
330 .BR pthread_getcpuclockid (3),