time

TIME(7)                    Linux Programmer's Manual                   TIME(7)



åå
       time - æéã¨ã¿ã¤ãã®æ¦è¦

説æ
   å®æé (real time) ã¨ããã»ã¹æé
       å®æéã¯ãç¹å®ã®æç¹ããè¨ã£ãæéã¨å®ç¾©ãããã ç¹å®ã®æç¹ã¨ã¯ãéå»ã®æ¨æºçãªæç¹
       (ä¸è¨ã®ç´å (Epoch) ã¨ã«ã¬ã³ãæå»ã®èª¬æãåç§) ãã ããã»ã¹ã®ä¸çã«ãããä½ããã®æç¹
       (ä¾ãã°ãéå§æ) ã§ãã (çµéæéããã»ã¹æéã¯ãããã»ã¹ã«ãã£ã¦ä½¿ãããç· CPU æéã¨å®ç¾©ãããã
       å¤ãã®å ´åãã¦ã¼ã¶æéã¨ã·ã¹ãã æéã«åããããã ã¦ã¼ã¶ CPU
       æéã¯ãã³ã¼ããã¦ã¼ã¶ã¢ã¼ãã§å®è¡ããã®ã«ä½¿ã£ãæéã§ããã ã·ã¹ãã  CPU æéã¯ããã®ãã‐
       ã»ã¹ã®ããã« ã«ã¼ãã«ãã·ã¹ãã ã¢ã¼ãã§å®è¡ããã®ã«ä½¿ã£ãæéã§ãã
       (ä¾ãã°ãã·ã¹ãã ã³ã¼ã«ãå®è¡ããã®ã«ä½¿ã£ãæé)ã time(1) ã³ãã³ãã¯ãã‐
       ã°ã©ã ã®å®è¡ã«è²»ãããç· CPU æéãè¨ãã®ã«ä½¿ç¨ãããã ããã°ã©ã ã¯ãèªèº«ãè²»ããç·
       CPU æéã times(2), getrusage(2), clock(3)  ã使ã£ã¦è¨ããã¨ãã§ããã

   ãã¼ãã¦ã§ã¢ã¯ããã¯
       å¤ãã®ã³ã³ãã¥ã¼ã¿ã (é»æ± ã§é§åããã) ãã¼ãã¦ã§ã¢ã¯ããã¯ãæã£ã¦ããã
       ã«ã¼ãã«ã¯èµ·åæã«ã½ããã¦ã§ã¢ã¯ããã¯ãåæåããããã« ãã¼ãã¦ã§ã¢ã¯ããã¯ãèªã¿è¾¼ãã
       ãã詳ããæå ±ã¯ã rtc(4)  㨠hwclock(8)  ãåç§ãããã¨ã

   ã½ããã¦ã§ã¢ã¯ããã¯, HZ, Jiffy
       ã¿ã¤ã ã¢ã¦ããè¨å®ããã (ä¾ãã° select(2), sigtimedwait(2))ã CPU æéãè¨æ¸¬ããã
       (ä¾ãã° getrusage(2))ããæ§ããªã·ã¹ãã ã³ã¼ã«ã®ç²¾åº¦ã¯ ã½ããã¦ã§ã¢ã¯ããã¯
       ã®åè§£è½ (resolution) ã«å¶éãããã ã½ããã¦ã§ã¢ã¯ããã¯ã¨ã¯ãã«ã¼ãã«ã管çãã
       jiffy åä½ã§æéãè¨æ¸¬ããã¯ããã¯ã®ãã¨ã§ããã jiffy ã®å¤§ããã¯ã«ã¼ãã«å®æ° HZ
       ã®å¤ã§æ±ºå®ãããã

       HZ ã®å¤ã¯ã«ã¼ãã«ã®ãã¼ã¸ã§ã³ã¨ãã¼ãã¦ã§ã¢ãã©ãããã©ã¼ã ã§ç°ãªãã i386
       ã®å ´åã¯ä»¥ä¸ã®éãã§ãã: 2.4.x ã¨ããããåã®ã«ã¼ãã«ã§ã¯ãHZ 㯠100 ã§ãã£ãã®ã§ã
       jiffy ã®å¤ã¯ 0.01 ç§ã«ãªã£ã¦ããã 2.6.0 以éã§ã¯ãHZ 㯠1000
       ã«å¢ããããã®ã§ãjiffy ã®å¤ã¯ 0.001 ç§ã§ããã ã«ã¼ãã« 2.6.13 以éã§ã¯ãHZ
       ã®å¤ã¯ã«ã¼ãã«è¨å®ãã©ã¡ã¼ã¿ã«ãªãã 100, 250 (ããã©ã«ã), 1000 ã¨ããå¤ã«ã§ããã
       ãããã jiffy ã®å¤ã¯ 0.01, 0.004, 0.001 ç§ã«ãªãã ã«ã¼ãã« 2.6.20
       以éã§ã¯ã300 ãå©ç¨ã§ããããã«ãªã£ã¦ããã 300
       ã¯ä¸è¬çãªæ åãã¬ã¼ã ã¬ã¼ãã®å¬åæ°ã§ãã (PAL, 25HZ; NTSC, 30HZ)ã

       times(2)  ã·ã¹ãã ã³ã¼ã«ã¯ç¹æ®ãªã±ã¼ã¹ã§ããã
       ãã®ã·ã¹ãã ã³ã¼ã«ã¯ã«ã¼ãã«å®æ° USER_HZ ã§å®ç¾©ãããç²åº¦ã§æéãå ±åããã
       ã¦ã¼ã¶ç©ºéã®ã¢ããªã±ã¼ã·ã§ã³ã¯ sysconf(_SC_CLK_TCK)
       ã使ã£ã¦ãã®å®æ°ã®å¤ãç¥ããã¨ãã§ããã

   é«ç²¾åº¦ã¿ã¤ã
       Linux 2.6.21 ããåã§ã¯ãã¿ã¤ããã¹ãªã¼ãé¢é£ã®ã·ã¹ãã ã³ã¼ã«ã®ç²¾åº¦ã jiffy
       ã®ãµã¤ãºã«ããå¶éããã¦ããã

       Linux 2.6.21 以éã§ã¯ãLinux ã¯é«ç²¾åº¦ã¿ã¤ã (high-resolution timers;
       HRTs)  ããµãã¼ããã¦ããã CONFIG_HIGH_RES_TIMERS ã§å¶å¾¡ã§ããã
       é«ç²¾åº¦ã¿ã¤ãããµãã¼ããã¦ããã·ã¹ãã ã§ã¯ãã¿ã¤ãã¨ã¹ãªã¼ãé¢é£ã®ã·ã¹ãã ã³ã¼ã«
       ã®ç²¾åº¦ã¯ãã¯ã jiffy ã«å¶ç´ããããã¨ã¯ãªãã ãã¼ãã¦ã§ã¢ã許ãéãã®ç²¾åº¦ã¨ãªã
       (æè¿ã®ãã¼ãã¦ã§ã¢ã§ã¯ãã¤ã¯ãç§åä½ã®ç²¾åº¦ãä¸è¬çã§ãã)ã
       é«ç²¾åº¦ã¿ã¤ãããµãã¼ãããã¦ãããã¯ã clock_getres(2)
       ãå¼ã³åºãã¦å解è½ã確èªãããã /proc/timer_list åã® "resolution"
       ã¨ã³ããªãåç§ãããã§å¤æã§ããã

       é«ç²¾åº¦ã¿ã¤ãã¯ãã¹ã¦ã®ãã¼ãã¦ã§ã¢ã¢ã¼ããã¯ãã£ã§ãµãã¼ãããã¦ãã 訳ã§ã¯ãªã
       (対å¿ãã¦ããã¢ã¼ããã¯ãã£ã¯ x86, arm, powerpc ã§ãã)ã

   ç´å
       UNIX ã·ã¹ãã ã¯æå»ã ç´å (1970-01-01 00:00:00 +0000 (UTC))
       ããã®ç§æ°ã§è¡¨ç¾ããã

       ããã°ã©ã 㯠ã«ã¬ã³ãæå» ã gettimeofday(2)  ã使ã£ã¦è¨ããã¨ãã§ããã
       ãã®é¢æ°ã¯ç´åããã®çµéæéã (ç§ã¨ãã¤ã¯ãç§ã§) è¿ãã time(2)
       ã¯åæ§ã®æå ±ãæä¾ããããæãè¿ãç§ã®ç²¾åº¦ãããªãã ã·ã¹ãã æå»ã¯ settimeofday(2)
       ã§å¤æ´ã§ããã

   è¦ç´ å¥ã®æå»
       ã©ã¤ãã©ãªé¢æ°ã®ä¸ã«ã¯ tm åã®æ§é ä½ã使ããã®ãããã
       ãã®æ§é ä½ã¯è¦ç´ å¥ã®æå»ã表ãã æå»ã®å¤ãå¥ãã®è¦ç´
       (å¹´ã»æã»æ¥ã»æã»åã»ç§ãªã©) ã«åãã¦æ ¼ç´ããã ãã®æ§é ä½ã¯ ctime(3)
       ã«è¨è¿°ããã¦ãããã«ã¬ã³ãæå»ãè¦ç´ å¥ã®æå»ã«å¤æãã é¢æ°ã«ã¤ãã¦ãè¨è¿°ããã¦ããã
       è¦ç´ å¥ã®æå»ã表示å¯è½ãªæååã«å¤æããé¢æ°ã«ã¤ãã¦ã¯ã ctime(3),
       strftime(3), strptime(3)  ã«è¨è¿°ããã¦ããã

   ã¿ã¤ãã®ã¹ãªã¼ãã¨è¨å®
       æ§ããªã·ã¹ãã ã³ã¼ã«ã¨é¢æ°ã«ãããæå®ãããä¸å®ã®æéã ããã°ã©ã ã¯ã¹ãªã¼ã
       (å®è¡ãåæ¢) ãããã¨ãå¯è½ã§ããã nanosleep(2), clock_nanosleep(2), sleep(3)
       ãåç§ãããã¨ã

       æ§ããªã·ã¹ãã ã³ã¼ã«ã«ãããããã»ã¹ã¯å°æ¥ã®ããæç¹ã§ æå¹æéãçµäºããã¿ã¤ããè¨‐
       å®ã§ããã ã¾ããªãã·ã§ã³ã¨ãã¦ç¹°ãè¿ãééãæå®ã§ãããã®ãããã alarm(2),
       getitimer(2), timerfd_create(2), timer_create(2) ãåç§ãããã¨ã

   Timer slack
       Since Linux 2.6.28, it is possible to control the "timer slack" value
       for a thread.  The timer slack is the length of time by which the
       kernel may delay the wake-up of certain system calls that block with a
       timeout.  Permitting this delay allows the kernel to coalesce wake-up
       events, thus possibly reducing the number of system wake-ups and saving
       power.  For more details, see the description of PR_SET_TIMERSLACK in
       prctl(2).

é¢é£é ç®
       date(1), time(1), adjtimex(2), alarm(2), clock_gettime(2),
       clock_nanosleep(2), getitimer(2), getrlimit(2), getrusage(2),
       gettimeofday(2), nanosleep(2), stat(2), time(2), timer_create(2),
       timerfd_create(2), times(2), utime(2), adjtime(3), clock(3),
       clock_getcpuclockid(3), ctime(3), pthread_getcpuclockid(3), sleep(3),
       strftime(3), strptime(3), timeradd(3), usleep(3), rtc(4), hwclock(8)

ãã®ææ¸ã«ã¤ãã¦
       ãã® man ãã¼ã¸ã¯ Linux man-pages ããã¸ã§ã¯ãã®ãªãªã¼ã¹ 3.51 ã®ä¸é¨
       ã§ãããããã¸ã§ã¯ãã®èª¬æã¨ãã°å ±åã«é¢ããæå ±ã¯
       http://www.kernel.org/doc/man-pages/ ã«æ¸ããã¦ããã



Linux                             2012-10-28                           TIME(7)