[lkml]   [2005]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [RFC - 0/9] Generic timekeeping subsystem (v. B5)

On Fri, 19 Aug 2005, john stultz wrote:

> timekeeping_perioidic_hook():
> /* get ntp adjusted interval length*/
> interval_length = get_timesource_interval(ppm)

Here starts the problem, this requires more expensive math than necessary,
as every time you first have to scale the values.

Let's take a standard PIT timer as an example. With HZ=100 we program it
with 11932, for simplicity let's assume this corresponds to 10^7ns and
scale this by 2^8. This means the timer multiplier is initially 214549,
this updates the system time by 214549*11932 and the reference time by
10^7*2^8 every tick. We can now just ignore the error or as soon as it
exceeds 11932/2 we increase/decrease the mutiplier. The error calculation
is rather simple, usually just adds and shifts, only if the error exceeds
2*11932 it gets a little more complicated, but even here the possible
divide is avoidable.
The gettimeofday would then basically be "xtime + (cycle_offset * mult +
error_offset) / 2^8". Depending on the update frequency and the required
precision it's even possible to keep this within 32bit. The ntp part stays
pretty much the same and the time source can add anything it wants on top
of that. The basic math is also pretty much the same so we can generate
most of the code depending on various parameters.

bye, Roman
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-08-22 01:22    [W:0.097 / U:0.112 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site