Timers (was Trivial pc-speaker problem.)

Matthew Dillon dillon at apollo.backplane.com
Mon Sep 27 07:52:54 PDT 2004


:  Thanks for the long answer.  But I don't get where hz comes from.  It's
:obviously not timer <not 0> then.  (And 18.2 Hz might be a bit slow.)
:
:  So is the "hz tick" just another event that timer 0 checks (and sets up
:an interval) for then?

    Right.  The 'hz' tick is just a periodic SYSTIMER in DFly, whereas in
    FreeBSD the 'hz' tick is the primary timer 0 timebase interrupt.

: (And is then timer <not 0> used to calculate how many cycles there are to
:go until the next tick?  (Since timer 0 is "unsuitable for keeping track
:of ''real'' time") )

    Right.  The timer <not 0> is used to calculate the elapsed time in 
    microsecond granularity.  It does not need to generate an interrupt
    or anything, it just needs to be consistent.  In fact, the TSC or APIC
    ltimer or other hardware timers could be used for this purpose (though
    each has its quirks, which is why I'd really like to use one of the
    8254 timers).  The real time clock (rtc) chip does not have enough 
    resolution to use for this purpose.

:  This stuff is interesting, had to think for a bit too.  Thanks again.
:
:Magnus

					-Matt
					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>





More information about the Kernel mailing list