Messages in this thread |  | | Date | Mon, 23 Oct 2000 10:18:07 -0500 (CDT) | From | Oliver Xymoron <> | Subject | Re: PC speaker driver patch for 2.4.0-test10-pre3 |
| |
On Mon, 23 Oct 2000, David Woodhouse wrote:
> See arch/i386/kernel/time.c: > > /* This function must be called with interrupts disabled > * It was inspired by Steve McCanne's microtime-i386 for BSD. -- jrs > * > * However, the pc-audio speaker driver changes the divisor so that > * it gets interrupted rather more often - it loads 64 into the > * counter rather than 11932! This has an adverse impact on > * do_gettimeoffset() -- it stops working! What is also not > * good is that the interval that our timer function gets called > * is no longer 10.0002 ms, but 9.9767 ms. To get around this > * would require using a different timing source.
You can also pretty trivially keep track of an error term so that the clock is right on average:
#define CLK_HZ 1193200 /* or whatever */ #define ET_PRECISION 1000 #define ET_TIMER_TICKS CLK_HZ*ET_PRECISION/HZ #define ET_PCSP_TICKS 64*ET_PRECISION ... static long et=0;
... et+=ET_PCSP_TICKS; if(et>ET_TIMER_TICKS) { et-=ET_TIMER_TICKS; simulate_timer_tick(); }
This keeps track of the residual timing error to a few decimal places to several decimal places and will get closer to HZ than even the current code.
-- "Love the dolphins," she advised him. "Write by W.A.S.T.E.."
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/
|  |