Re: HZ, preferably as small as possible

george anzinger
2002-07-12T01:07:13Z

Stevie O wrote:
>
> At <date>, <user> [<email>] wrote:
> > <stuff>
>
> A lot of people are talking about how HZ needs to be a constant, etc.
>
> I don't do much kernel hacking, so allow me to post a query that would (probably) better belong on #kernelnewbies if I wasn't so damn lazy ;) --
>
> Why must HZ be the same as 'interrupts per second'?

Well, in truth it has nothing to do with interrupts. It is
just that that is the way most systems keep time. The REAL
definition of HZ is in its relationship to jiffies and
seconds.

I.e. jiffies * HZ = seconds, by definition.

Then we define interfaces that promise to return so many
jiffies from now and we keep execution time and time slice
times in jiffies. In order to keep these things true, it is
usual to set up some sort of timer to interrupt once each
jiffie. Now we can actually do this two ways. We can say
that the interrupt is a reminder to look at a "reliable
clock" and update the system time with what we find OR we
can use the interrupt to actually drive the system time.
The former is the more accurate way of doing things as it
eliminates interrupt latency. It also allows us to use a
more sloppy source of interrupts since they are just
reminders to check a clock and not actually driving the
clock. This, by the way, is what the high-res-timers patch
does. Doing things this way also allows one to reprogram
the timer interrupt hardware with out worrying too much
about loosing track of time. The HRT patch does this to
generate interrupts at sub jiffie intervals, but only when
required.

-g
>
> --
> Stevie-O
>
> Real programmers link their executables by hand.
>

--
George Anzinger george@mvista.com
High-res-timers:
http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/