OSDN Git Service

36894ebf9884423e4010a292c9beada1d70ee223
[linuxjm/LDP_man-pages.git] / draft / man7 / time.7
1 .\" Copyright (c) 2006 by Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
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.
6 .\"
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.
11 .\"
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
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" 2008-06-24, mtk: added some details about where jiffies come into
24 .\"     play; added section on high-resolution timers.
25 .\"
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
31 .\"
32 .TH TIME 7 2010-02-25 "Linux" "Linux Programmer's Manual"
33 .\"O .SH NAME
34 .SH 名前
35 .\"O time \- overview of time and timers
36 time \- 時間とタイマの概要
37 .\"O .SH DESCRIPTION
38 .SH 説明
39 .\"O .SS "Real time and process time"
40 .SS "実時間 (real time) とプロセス時間"
41 .\"O .I "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は、特定の時点から計った時間と定義される。
48 特定の時点とは、過去の標準的な時点
49 (下記の紀元 (Epoch) とカレンダ時刻の説明を参照) や、
50 プロセスの一生における何らかの時点 (例えば、開始時) である
51 .RI ( "経過時間" )。
52
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
56 .\"O .I user
57 .\"O and
58 .\"O .I system
59 .\"O components.
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 (例えば、システムコールを実行するのに使った時間)。
69 .\"O The
70 .\"O .BR time (1)
71 .\"O command can be used to determine the amount of CPU time consumed
72 .\"O during the execution of a program.
73 .BR time (1)
74 コマンドはプログラムの実行に費された総 CPU 時間を計るのに使用される。
75 .\"O A program can determine the amount of CPU time it has consumed using
76 .\"O .BR times (2),
77 .\"O .BR getrusage (2),
78 .\"O or
79 .\"O .BR clock (3).
80 プログラムは、自身が費した総 CPU 時間を
81 .BR times (2),
82 .BR getrusage (2),
83 .BR clock (3)
84 を使って計ることができる。
85 .\"O .SS "The Hardware Clock"
86 .SS ハードウェアクロック
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 カーネルは起動時にソフトウェアクロックを初期化するために
91 ハードウェアクロックを読み込む。
92 .\"O For further details, see
93 .\"O .BR rtc (4)
94 .\"O and
95 .\"O .BR hwclock (8).
96 より詳しい情報は、
97 .BR rtc (4)
98
99 .BR hwclock (8)
100 を参照すること。
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,
105 .\"O (e.g.,
106 .\"O .BR select (2),
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
115 .\"O .IR jiffies .
116 .\"O The size of a jiffy is determined by the value of the kernel constant
117 .\"O .IR HZ .
118 タイムアウトを設定したり (例えば
119 .BR select (2),
120 .BR sigtimedwait (2))、
121 .\" semtimedop(), mq_timedwait(), io_getevents(), poll() は同じ futex であり、
122 .\" したがっって sem_timedwait() は高精度タイマを使用しているようである。
123 CPU 時間を計測したり (例えば
124 .BR getrusage (2)) する様々なシステムコールの精度は
125 .I ソフトウェアクロック
126 の分解能 (resolution) に制限される。
127 ソフトウェアクロックとは、カーネルが管理する
128 .I jiffy
129 単位で時間を計測するクロックのことである。
130 jiffy の大きさはカーネル定数
131 .I HZ
132 の値で決定される。
133
134 .\"O The value of
135 .\"O .I HZ
136 .\"O varies across kernel versions and hardware platforms.
137 .I HZ
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
143 .\"O 0.001 seconds.
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.
147 i386 の場合は以下の通りである:
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)。
159
160 .\"O The
161 .\"O .BR times (2)
162 .\"O system call is a special case.
163 .\"O It reports times with a granularity defined by the kernel constant
164 .\"O .IR USER_HZ .
165 .\"O Userspace applications can determine the value of this constant using
166 .\"O .IR sysconf(_SC_CLK_TCK) .
167 .BR times (2)
168 システムコールは特殊なケースであり、
169 このシステムコールはカーネル定数
170 .I USER_HZ
171 で定義された粒度で時間を報告する。
172 ユーザ空間のアプリケーションは
173 .I sysconf(_SC_CLK_TCK)
174 を使ってこの定数の値を知ることができる。
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.
177 .\"
178 .\"O .SS "High-Resolution Timers"
179 .SS "高精度タイマ"
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 のサイズにより制限されていた。
184
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)
198 をサポートしており、
199 .B CONFIG_HIGH_RES_TIMERS
200 で制御できる。
201 高精度タイマをサポートしているシステムでは、タイマとスリープ関連のシステムコール
202 の精度はもはや jiffy に制約されることはなく、
203 ハードウェアが許す限りの精度となる
204 (最近のハードウェアではマイクロ秒単位の精度が一般的である)。
205 高精度タイマがサポートされているかは、
206 .BR clock_getres (2)
207 を呼び出して分解能を確認するか、
208 .I /proc/timer_list
209 内の "resolution" エントリを参照するかで判断できる。
210
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 である)。
215 .\"O .SS "The Epoch"
216 .SS "紀元"
217 .\"O UNIX systems represent time in seconds since the
218 .\"O .IR Epoch ,
219 .\"O 1970-01-01 00:00:00 +0000 (UTC).
220 UNIX システムは時刻を
221 紀元 (1970-01-01 00:00:00 +0000 (UTC)) からの秒数で表現する。
222
223 .\"O A program can determine the
224 .\"O .I "calendar time"
225 .\"O using
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 を
230 .BR gettimeofday (2)
231 を使って計ることができる。
232 この関数は紀元からの経過時間を (秒とマイクロ秒で) 返す。
233 .\"O .BR time (2)
234 .\"O provides similar information, but only with accuracy to the
235 .\"O nearest second.
236 .\"O The system time can be changed using
237 .\"O .BR settimeofday (2).
238 .BR time (2)
239 は同様の情報を提供するが、最も近い秒の精度しかない。
240 システム時刻は
241 .BR settimeofday (2)
242 で変更できる。
243 .\"O .SS "Broken-down time"
244 .SS "要素別の時刻"
245 .\"O Certain library functions use a structure of
246 .\"O type
247 .\"O .I tm
248 .\"O to represent
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.).
252 ライブラリ関数の中には
253 .I tm
254 型の構造体を使うものがある。
255 この構造体は\fI要素別の時刻\fRを表し、
256 時刻の値を別々の要素 (年・月・日・時・分・秒など) に分けて格納する。
257 .\"O This structure is described in
258 .\"O .BR ctime (3),
259 .\"O which also describes functions that convert between calendar time and
260 .\"O broken-down time.
261 この構造体は
262 .BR ctime (3)
263 に記述されており、カレンダ時刻を要素別の時刻に変換する
264 関数についても記述されている。
265 .\"O Functions for converting between broken-down time and printable
266 .\"O string representations of the time are described in
267 .\"O .BR ctime (3),
268 .\"O .BR strftime (3),
269 .\"O and
270 .\"O .BR strptime (3).
271 要素別の時刻を表示可能な文字列に変換する関数については、
272 .BR ctime (3),
273 .BR strftime (3),
274 .BR strptime (3)
275 に記述されている。
276 .\"O .SS "Sleeping and Setting Timers"
277 .SS "タイマのスリープと設定"
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),
282 .\"O and
283 .\"O .BR sleep (3).
284 様々なシステムコールと関数により、指定された一定の時間、
285 プログラムはスリープ (実行を停止) することが可能である。
286 .BR nanosleep (2),
287 .BR clock_nanosleep (2),
288 .BR sleep (3)
289 を参照すること。
290
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;
293 .\"O see
294 .\"O .BR alarm (2),
295 .\"O .BR getitimer (2),
296 .\"O .BR timerfd_create (2),
297 .\"O and
298 .\"O .BR timer_create (2).
299 様々なシステムコールにより、プロセスは将来のある時点で
300 有効期間が終了するタイマを設定できる。
301 またオプションとして繰り返し間隔が指定できるものもある。
302 .BR alarm (2),
303 .BR getitimer (2),
304 .BR timerfd_create (2),
305 .BR timer_create (2)
306 を参照すること。
307 .\"O .SH "SEE ALSO"
308 .SH 関連項目
309 .BR date (1),
310 .BR time (1),
311 .BR adjtimex (2),
312 .BR alarm (2),
313 .BR clock_gettime (2),
314 .BR clock_nanosleep (2),
315 .BR getitimer (2),
316 .BR getrlimit (2),
317 .BR getrusage (2),
318 .BR gettimeofday (2),
319 .BR nanosleep (2),
320 .BR stat (2),
321 .BR time (2),
322 .BR timer_create (2),
323 .BR timerfd_create (2),
324 .BR times (2),
325 .BR utime (2),
326 .BR adjtime (3),
327 .BR clock (3),
328 .BR clock_getcpuclockid (3),
329 .BR ctime (3),
330 .BR pthread_getcpuclockid (3),
331 .BR sleep (3),
332 .BR strftime (3),
333 .BR strptime (3),
334 .BR timeradd (3),
335 .BR usleep (3),
336 .BR rtc (4),
337 .BR hwclock (8)