This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / Documentation / time_interpolators.txt
1 Time Interpolators
2 ------------------
3
4 Time interpolators are a base of time calculation between timer ticks and
5 allow an accurate determination of time down to the accuracy of the time
6 source in nanoseconds.
7
8 The architecture specific code typically provides gettimeofday and
9 settimeofday under Linux. The time interpolator provides both if an arch
10 defines CONFIG_TIME_INTERPOLATION. The arch still must set up timer tick
11 operations and call the necessary functions to advance the clock.
12 With the time interpolator a standardized interface exists for time
13 interpolation between ticks which also allows the determination
14 of time in a hardware independent way. The provided logic is highly scalable
15 and has been tested in SMP situations of up to 512 CPUs.
16
17 If CONFIG_TIME_INTERPOLATION is defined then the architecture specific code
18 (or the device drivers - like HPET) must register time interpolators.
19 These are typically defined in the following way:
20
21 static struct time_interpolator my_interpolator;
22
23 void time_init(void)
24 {
25         ....
26         /* Initialization of the timer *.
27         my_interpolator.frequency = MY_FREQUENCY;
28         my_interpolator.source = TIME_SOURCE_MMIO32;
29         my_interpolator.address = &my_timer;
30         my_interpolator.shift = 32;             /* increase accuracy of scaling */
31         my_interpolator.drift = -1;             /* Unknown */
32         my_interpolator.jitter = 0;             /* A stable time source */
33         register_time_interpolator(&my_interpolator);
34         ....
35 }
36
37 For more details see include/linux/timex.h.
38
39 Christoph Lameter <christoph@lameter.com>, September 8, 2004
40