OSDN Git Service

c12268a5f9cffcc81b5b8fb6bbb50a2ce7559ba3
[linuxjm/LDP_man-pages.git] / release / man2 / clock_getres.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 2003 Nick Clifford (zaf@nrc.co.nz), Jan 25, 2003
4 .\" Copyright (c) 2003 Andries Brouwer (aeb@cwi.nl), Aug 24, 2003
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\"
26 .\" 2003-08-23 Martin Schulze <joey@infodrom.org> improvements
27 .\" 2003-08-24 aeb, large parts rewritten
28 .\" 2004-08-06 Christoph Lameter <clameter@sgi.com>, SMP note
29 .\"
30 .\" Japanese Version Copyright (c) 2004-2005 Yuichi SATO
31 .\"         all rights reserved.
32 .\" Translated 2004-07-19, Yuichi SATO <ysato444@yahoo.co.jp>
33 .\" Updated & Modified 2005-01-10, Yuichi SATO
34 .\" Updated 2010-04-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
35 .\"
36 .TH CLOCK_GETRES 2 2010-02-03 "" "Linux Programmer's Manual"
37 .SH Ì¾Á°
38 clock_getres, clock_gettime, clock_settime \- ¥¯¥í¥Ã¥¯¤È»þ´Ö¤Î´Ø¿ô
39 .SH ½ñ¼°
40 .B #include <time.h>
41 .sp
42 .BI "int clock_getres(clockid_t " clk_id ", struct timespec *" res );
43
44 .BI "int clock_gettime(clockid_t " clk_id ", struct timespec *" tp );
45
46 .BI "int clock_settime(clockid_t " clk_id ", const struct timespec *" tp );
47 .sp
48 \fI\-lrt\fP ¤È¥ê¥ó¥¯¤¹¤ë¡£
49 .sp
50 .in -4n
51 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
52 .RB ( feature_test_macros (7)
53 »²¾È):
54 .in
55 .sp
56 .ad l
57 .BR clock_getres (),
58 .BR clock_gettime (),
59 .BR clock_settime ():
60 _POSIX_C_SOURCE\ >=\ 199309L
61 .ad b
62 .SH ÀâÌÀ
63 ´Ø¿ô
64 .BR clock_getres ()
65 ¤Ï
66 »ØÄꤵ¤ì¤¿¥¯¥í¥Ã¥¯
67 .I clk_id
68 ¤Îʬ²òǽ (ÀºÅÙ) ¤òõ¤·½Ð¤¹¡£
69 .I res
70 ¤¬ NULL ¤Ç¤Ê¤¤¾ì¹ç¡¢¤½¤Îʬ²òǽ¤ò
71 .I res
72 ¤Ç»Ø¤µ¤ì¤ë \fIstruct timespec\fP ¤Ë³ÊǼ¤¹¤ë¡£
73 ¥¯¥í¥Ã¥¯¤Îʬ²òǽ¤Ï¼ÂÁõ¤Ë°Í¸¤·¡¢
74 ÆÃÄê¤Î¥×¥í¥»¥¹¤Ë¤è¤Ã¤ÆÀßÄꤹ¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£
75 .BR clock_settime ()
76 ¤Î°ú¤­¿ô
77 .I tp
78 ¤Ç»Ø¤µ¤ì¤ë»þ´Ö¤ÎÃͤ¬
79 .I res
80 ¤ÎÇÜ¿ô¤Ç¤Ê¤¤¾ì¹ç¡¢
81 .I res
82 ¤ÎÇÜ¿ô¤ËÀÚ¤êµÍ¤á¤é¤ì¤ë¡£
83 .PP
84 ´Ø¿ô
85 .BR clock_gettime ()
86 ¤È
87 .BR clock_settime ()
88 ¤Ï¡¢»ØÄꤵ¤ì¤¿¥¯¥í¥Ã¥¯
89 .I clk_id
90 ¤Î»þ´Ö¤ò¼èÆÀ¤Þ¤¿¤ÏÀßÄꤹ¤ë¡£
91 .PP
92 .I res
93 ¤È
94 .I tp
95 °ú¤­¿ô¤Ï
96 .I timespec
97 ¹½Â¤ÂΤǤ¢¤ê¡¢
98 .I <time.h>
99 ¤Ç°Ê²¼¤Î¤è¤¦¤Ëµ¬Äꤵ¤ì¤Æ¤¤¤ë:
100 .sp
101 .in +4n
102 .nf
103 struct timespec {
104     time_t   tv_sec;        /* seconds */
105     long     tv_nsec;       /* nanoseconds */
106 };
107 .fi
108 .in
109 .PP
110 .I clk_id
111 °ú¤­¿ô¤ÏÆÃÄê¤Î¥¯¥í¥Ã¥¯¤Î¼±Ê̻ҤǤ¢¤ê¡¢¤½¤Î¥¯¥í¥Ã¥¯¤ÇÆ°ºî¤¹¤ë¡£
112 ¥¯¥í¥Ã¥¯¤Ï¥·¥¹¥Æ¥àÁ´ÂΤËŬÍѤ¹¤ë¤³¤È¤â¤Ç¤­¡¢
113 ¤½¤Î¾ì¹ç¤ÏÁ´¤Æ¤Î¥×¥í¥»¥¹¤«¤é¸«¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
114 ¤Þ¤¿ 1 ¤Ä¤Î¥×¥í¥»¥¹Æâ¤Ç¤Î¤ß»þ´Ö¤ò·×¬¤¹¤ë¾ì¹ç¤Ï¡¢
115 ¥×¥í¥»¥¹Ëè¤ËŬÍѤ¹¤ë¤³¤È¤â¤Ç¤­¤ë¡£
116 .LP
117 Á´¤Æ¤Î¼ÂÁõ¤Ë¤ª¤¤¤Æ¥·¥¹¥Æ¥àÁ´ÂΤΥꥢ¥ë¥¿¥¤¥à¥¯¥í¥Ã¥¯¤¬¥µ¥Ý¡¼¥È¤µ¤ì¡¢
118 .B CLOCK_REALTIME
119 ¤Ç¼±Ê̤µ¤ì¤ë¡£
120 »þ´Ö¤Ïµª¸µ (the Epoch) ¤«¤é¤ÎÉäȥʥÎÉäÇɽ¤µ¤ì¤ë¡£
121 »þ´Ö¤¬Êѹ¹¤µ¤ì¤¿¾ì¹ç¡¢ÁêÂÐŪ¤Ê»þ´Ö´Ö³Ö¤Î¥¿¥¤¥Þ¤Ï±Æ¶Á¤ò¼õ¤±¤Ê¤¤¤¬¡¢
122 ÀäÂÐŪ¤Ê»þÅÀ¤Î¥¿¥¤¥Þ¤Ï±Æ¶Á¤ò¼õ¤±¤ë¡£
123 .LP
124 ¤µ¤é¤Ë¤¤¤¯¤Ä¤«¤Î¥¯¥í¥Ã¥¯¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
125 Âбþ¤¹¤ë»þ´Ö¤ÎÃͤò²ò¼á¤¹¤ëÊýË¡¤È¥¿¥¤¥Þ¤Ø¤Î±Æ¶Á¤Ï¡¢Äê¤á¤é¤ì¤Æ¤¤¤Ê¤¤¡£
126 .LP
127 glibc ¤È Linux ¥«¡¼¥Í¥ë¤ÎºÇ¿·¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¡¢
128 °Ê²¼¤Î¤è¤¦¤Ê½½Ê¬¤Ê¥¯¥í¥Ã¥¯¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¡£
129 .TP
130 .B CLOCK_REALTIME
131 ¥·¥¹¥Æ¥àÁ´ÂΤΥꥢ¥ë¥¿¥¤¥à¥¯¥í¥Ã¥¯¡£
132 ¤³¤Î¥¯¥í¥Ã¥¯¤òÀßÄꤹ¤ë¤Ë¤ÏŬÀÚ¤ÊÆø¢¤¬É¬ÍפǤ¢¤ë¡£
133 .TP
134 .B CLOCK_MONOTONIC
135 ¤¤¤¯¤Ä¤«¤Î³«»ÏÅÀ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¤¿¤á¡¢
136 ¥¯¥í¥Ã¥¯¤¬¥â¥Î¥È¥Ë¥Ã¥¯¥¿¥¤¥à¤òÀßÄꤷ¤¿¤êɽ¸½¤·¤¿¤ê¤Ç¤­¤Ê¤¤¡£
137 .TP
138 .BR CLOCK_MONOTONIC_RAW " (Linux 2.6.28 °Ê¹ß; Linux ÆÃÍ­)"
139 .\" Added in commit 2d42244ae71d6c7b0884b5664cf2eda30fb2ae68, John Stultz
140 .B CLOCK_MONOTONIC
141 ¤ÈƱÍͤÀ¤¬¡¢NTP ¤Ë¤è¤ëÄ´À°¤Î±Æ¶Á¤ò¼õ¤±¤Ê¤¤¡¢¥Ï¡¼¥É¥¦¥§¥¢¤Ë¤è¤ë
142 À¸¤Î»þ¹ï¤Ø¤Î¥¢¥¯¥»¥¹¤¬¤Ç¤­¤ë¡£
143 .TP
144 .B CLOCK_PROCESS_CPUTIME_ID
145 CPU ¤Ë¤è¤ë¹âʬ²òǽ¤Î¥×¥í¥»¥¹Ëè¤Î¥¿¥¤¥Þ¡£
146 .TP
147 .B CLOCK_THREAD_CPUTIME_ID
148 ¥¹¥ì¥Ã¥É¸ÇÍ­¤Î CPU ¥¿¥¤¥à¥¯¥í¥Ã¥¯¡£
149 .SH ÊÖ¤êÃÍ
150 .BR clock_gettime (),
151 .BR clock_settime (),
152 .BR clock_getres ()
153 ¤ÏÀ®¸ù¤·¤¿¾ì¹ç¤Ë 0 ¤òÊÖ¤·¡¢¼ºÇÔ¤·¤¿¾ì¹ç¤Ë \-1 ¤òÊÖ¤¹
154 (¼ºÇÔ¤·¤¿¾ì¹ç¡¢
155 .I errno
156 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë)¡£
157 .SH ¥¨¥é¡¼
158 .TP
159 .B EFAULT
160 .I tp
161 ¤¬¥¢¥¯¥»¥¹²Äǽ¤Ê¥¢¥É¥ì¥¹¶õ´Ö¤Î³°¤ò»Ø¤·¤¿¡£
162 .TP
163 .B EINVAL
164 .\" Linux also gives this error on attempts to set CLOCK_PROCESS_CPUTIME_ID
165 .\" and CLOCK_THREAD_CPUTIME_ID, when probably the proper error should be
166 .\" EPERM.
167 »ØÄꤵ¤ì¤¿
168 .I clk_id
169 ¤¬¤³¤Î¥·¥¹¥Æ¥à¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
170 .TP
171 .B EPERM
172 »Ø¼¨¤µ¤ì¤¿¥¯¥í¥Ã¥¯¤òÀßÄꤹ¤ë¸¢¸Â¤¬
173 .BR clock_settime ()
174 ¤Ë¤Ê¤¤¡£
175 .SH ½àµò
176 SUSv2, POSIX.1-2001.
177 .SH ²ÄÍÑÀ­
178 ¤³¤ì¤é¤Î´Ø¿ô¤¬ÍøÍѲÄǽ¤Ê POSIX ¥·¥¹¥Æ¥à¤Ç¤Ï¡¢\fI<unistd.h>\fP ¤Ë¤ª¤¤¤Æ¥·¥ó¥Ü¥ë
179 .B _POSIX_TIMERS
180 ¤¬ 0 ¤è¤êÂ礭¤¤ÃͤËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
181 ¥·¥ó¥Ü¥ë
182 .BR _POSIX_MONOTONIC_CLOCK ,
183 .BR _POSIX_CPUTIME ,
184 .B _POSIX_THREAD_CPUTIME
185 ¤Ï
186 .BR CLOCK_MONOTONIC ,
187 .BR CLOCK_PROCESS_CPUTIME_ID ,
188 .B CLOCK_THREAD_CPUTIME_ID
189 ¤¬ÍøÍѲÄǽ¤Ê¤³¤È¤ò¼¨¤¹¡£
190 .RB ( sysconf (3)
191 ¤â»²¾È¤¹¤ë¤³¤È¡£)
192 .SH Ãí°Õ
193 .SS "SMP ¥·¥¹¥Æ¥à¤Ë¤Ä¤¤¤Æ¤ÎÃí°Õ"
194 .B CLOCK_PROCESS_CPUTIME_ID
195 ¤È
196 .B CLOCK_THREAD_CPUTIME_ID
197 ¥¯¥í¥Ã¥¯¤Ï¡¢CPU ¤«¤é¤Î¥¿¥¤¥Þ
198 (i386 ¾å¤Î TSC¡¢Itanium ¾å¤Î AR.ITC) ¤òÍѤ¤¤Æ¼Â¸½¤µ¤ì¤Æ¤¤¤ë¡£
199 ¤³¤ì¤é¤Î¥ì¥¸¥¹¥¿¤Ï CPU ´Ö¤Ç°Û¤Ê¤ë²ÄǽÀ­¤¬¤¢¤ê¡¢
200 ¥×¥í¥»¥¹¤¬Â¾¤Î CPU ¤Ë°ÜÆ°¤µ¤»¤é¤ì¤¿¾ì¹ç¡¢
201 ·ë²Ì¤È¤·¤Æ¤³¤ì¤é¤Î¥¯¥í¥Ã¥¯¤¬\fBµ¶¤Î·ë²Ì\fR
202 (bogus results) ¤òÊÖ¤¹¤«¤â¤·¤ì¤Ê¤¤¡£
203 .PP
204 SMP ¥·¥¹¥Æ¥à¤Î³Æ CPU ¤¬ÊÌ¡¹¤Î¥¯¥í¥Ã¥¯¸»¤ò»ý¤Ä¾ì¹ç¡¢
205 ¥¿¥¤¥Þ¥ì¥¸¥¹¥¿´Ö¤ÎÁê¸ß´Ø·¸¤ò´ÉÍý¤¹¤ëÊýË¡¤Ï¤Ê¤¤¡£
206 ¤³¤ì¤Ï³Æ CPU ¤¬Èù̯¤Ë°Û¤Ê¤ë¼þÇÈ¿ô¤ÇÆ°ºî¤¹¤ë¤¿¤á¤Ç¤¢¤ë¡£
207 ¤³¤ì¤¬¿¿¼Â¤Î¾ì¹ç (ÌõÃð: ³Æ CPU ¤¬ÊÌ¡¹¤Î¥¯¥í¥Ã¥¯¸»¤ò»ý¤Ä¾ì¹ç)¡¢
208 .I clock_getcpuclockid(0)
209 ¤Ï
210 .B ENOENT
211 ¤òÊÖ¤·¤Æ¡¢¤½¤Î¾õ¶·¤òɽ¤¹¡£
212 2 ¤Ä¤Î¥¯¥í¥Ã¥¯¤Ï¡¢¥×¥í¥»¥¹¤¬ÆÃÄê¤Î CPU ¾å¤Ëα¤Þ¤Ã¤Æ¤¤¤ë¤³¤È¤¬
213 ÊݾڤǤ­¤ë¾ì¹ç¤Ë¤Î¤ßÍ­¸ú¤Ç¤¢¤ë¡£
214 .PP
215 SMP ¥·¥¹¥Æ¥à¤Î³Æ¥×¥í¥»¥Ã¥µ¤ÏÁ´¤¯Æ±¤¸»þ¹ï¤Ëµ¯Æ°¤¹¤ëÌõ¤Ç¤Ï¤Ê¤¤¤Î¤Ç¡¢
216 ³Æ¥¿¥¤¥Þ¥ì¥¸¥¹¥¿¤ÏÄ̾ï¤Ï¤¢¤ë¥ª¥Õ¥»¥Ã¥È¤ÇÆ°ºî¤·¤Æ¤¤¤ë¡£
217 ¥ª¥Õ¥»¥Ã¥È¤ò¥Ö¡¼¥È»þ¤ËÀ©¸Â¤¹¤ë¥³¡¼¥É¤¬´Þ¤Þ¤ì¤ë¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤â¤¢¤ë¡£
218 ¤·¤«¤·¡¢¤³¤Î¥³¡¼¥É¤¬¥ª¥Õ¥»¥Ã¥È¤òÀµ³Î¤ËÄ´À°¤¹¤ë¤³¤È¤ÏÊݾڤǤ­¤Ê¤¤¡£
219 glibc ¤Ï (Linux ¥«¡¼¥Í¥ë¤È¤Ï°Û¤Ê¤ê) ¥ª¥Õ¥»¥Ã¥È¤ò°·¤¦¤¿¤á¤Î¥³¡¼¥É¤òÄ󶡤·¤Ê¤¤¡£
220 Ä̾ï¤Ï¤³¤ì¤é¤Î¥ª¥Õ¥»¥Ã¥È¤¬¾®¤µ¤¤¤Î¤Ç¡¢Â¿¤¯¤Î¾ì¹ç¤Ç¤½¤Î±Æ¶Á¤Ï̵»ë¤Ç¤­¤ë¡£
221 .SH ¥Ð¥°
222 POSIX.1-2001 ¤Ç¤Ï¡¢
223 ¡ÖŬÀÚ¤ÊÆø¢ (appropriate privileges)¡×¤ò»ý¤Ã¤¿¥×¥í¥»¥¹¤Ï¡¢
224 .BR clock_settime ()
225 ¤ò»È¤Ã¤Æ¡¢¥¯¥í¥Ã¥¯
226 .B CLOCK_PROCESS_CPUTIME_ID
227 ¤È
228 .B CLOCK_THREAD_CPUTIME_ID
229 ¤òÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¤È¤µ¤ì¤Æ¤¤¤ë¡£
230 Linux ¤Ç¤Ï¡¢¤³¤ì¤é¤Î¥¯¥í¥Ã¥¯¤ÏÀßÄê²Äǽ¤Ç¤Ï¤Ê¤¤
231 (¤¹¤Ê¤ï¤Á¡¢¤É¤Î¥×¥í¥»¥¹¤â¡ÖŬÀÚ¤ÊÆø¢¡×¤ò»ý¤¿¤Ê¤¤)¡£
232 .\" See http://bugzilla.kernel.org/show_bug.cgi?id=11972
233 .SH ´ØÏ¢¹àÌÜ
234 .BR date (1),
235 .BR adjtimex (2),
236 .BR gettimeofday (2),
237 .BR settimeofday (2),
238 .BR time (2),
239 .BR clock_getcpuclockid (3),
240 .BR ctime (3),
241 .BR ftime (3),
242 .BR pthread_getcpuclockid (3),
243 .BR sysconf (3),
244 .BR time (7)