Precise timekeeping is critical for many computer applications: make(1) depends fully on timestamps of multi-dependent files to ensure building correctness; cron(8) run scheduled tasks based on the current time; some network protocols and measuring tools, such as UDT[1], thrulay[2] and owamp[3], make action decisions and network statistics according to the timestamp of sent/received packets. Incorrect and/or inprecise time will bring negative effects to these applications, more or less.
Time sources for a desktop computer could be divided into two major categories: external and local. Representative external sources are NTP servers and GPS timing receivers, and are beyond the topic of this article. We are interested in the local time sources. There are three of them:
date
. Update of this roughly at 10ms inteval. The exact rate depends on your particular system and on Linux it is determined by the constant, HZ. However, the gettimeofday()
is reporting time at microsecond interval. The way it achieves that is by interpolating TSC register ticks to microsecond level time. The rate is determined at system start up.The motivation of TSC-I2 is to provide accurate and precise time, i.e. a clock that minimizes both offset and interpolation error. We assume system clock is synchonized with NTP server, whose accuracy could be guranteed. In that way, we can use system clock as a reliable time reference with relatively low precision, and take advantage of TSC register's high resolution to achieve precision. This assumption of system clock accuracy is very important for the following sections.
[1] http://udt.sourceforge.net/.