[ntp:questions] drifting on crystal

David Woolley david at djwhome.demon.co.uk
Sat Jan 22 10:07:58 UTC 2005


In article <87d5vylijw.fsf at prep.synonet.com>,
prep at prep.synonet.com wrote:

> All the time tick interupt code has to do is increment a counter,
> and return.

> When the system get back to exit to the user or idle loop, it tests the

Hardware generally doesn't work like that.  An interrupt on its own
will return to the point of interrupt without any additional software
being run, so any ISR that wants code run at base level has to do rather
more work to schedule that code.

Also:

- timer interrupts are generally not the highest hardware interrupt priority;

- timer interrupts are used for simulating interrupts in hardware without
  it's own interrupt hardware, so the interrupt code can actually be run for
  many devices;

- modern expectations of NTP require the TSC be read during the interrupt
  service routine, so it is not just a case of updating a counter - more
  generally, the kernel time discipline and PPS operation really require 
  all these things to be done at the time of interrupt.

- particularly on Intel architecture machines, selectiving masking interrupts
  in a device driver is fiddly, so they tend (particularly on Linux) to simply
  turn off all interrupts for the critical region).

> tick counter and if it is not zero, runs the `clock tick' code. Wash,
> rinse...

> This allows you to run with out ever masking out the clock interupt.

Lots of parts of most systems disable all interrupts in various places, 
although ususally for rather short times.

Having said that, Linux interrupt handling is not very sophisticated.



More information about the questions mailing list