计算机里的时钟和定时器 - Clock & Timer

  1. Hardware Clock
    • rtc(4) hwclock(8)
  2. Software Clock, HZ, jiffies
    • HZ = (100, 250, 300, 1000)
    • USER_HZ = sysconf(_SC_CLK_TCK)
  3. High-Resolution Timer
    • clock_getres(2)
    • cat /proc/timer_list | fgrep resolution
  4. The Epoch - time since 1970-01-01 00:00:00 +0000 (UTC)
    • gettimeofday(2) - in seconds and microseconds
    • time(2) - in seconds
  5. Broken-down time
    • struct tm
  6. Sleeping & Timer
    • sleep
    • nanosleep()
    • clock_nanosleep()
    • alarm()
    • getitimer()
    • timerfd_create()
    • timer_create()
  7. Timer Slack - allow delay of timer wakeup