Re: HZ, preferably as small as possible

From: Stevie O (oliver@klozoff.com)
Date: Thu Jul 11 2002 - 20:35:47 EST


At 06:09 PM 7/11/2002 -0700, george anzinger wrote:
>> 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.

So why not do it this way:

1. Let HZ = 1000.

2. Program PIT (having programmed the PC speaker in DOS, I personally believe Intel forgot the 'A' at the end of the name) to fire every 10ms.

3. void pit_isr(void) { jiffies += 10; do_other_stuff(); }

--
Stevie-O

Real programmers use COPY CON PROGRAM.EXE

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jul 15 2002 - 22:00:21 EST