From: Alan Cox Date: Thu, 20 Sep 2018 00:54:55 +0000 (+0100) Subject: timer: handle fast clocks X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=d4a8f0b41b5d7723446afa524a35adb93d8cad6f;p=FUZIX.git timer: handle fast clocks On a few systems the timer tick can run too fast (eg it's 0.512 of a second not 0.5) and we can tick ahead of the RTC time. For robustness treat being a second ahead of locked time as we do being on time - don't tick again so we'll slide into time. We shouldn't end up any further out because the big jumps are only when we have interrupts off for stuff like floppy disk I/O. In that situation we will always lose time. --- diff --git a/Kernel/timer.c b/Kernel/timer.c index b0ad2ecf..78110943 100644 --- a/Kernel/timer.c +++ b/Kernel/timer.c @@ -112,10 +112,11 @@ void updatetod(void) slide = rtcnew - rtcsec; /* Seconds elapsed */ rtcsec = rtcnew; /* - * FIXME: it would be nice if we see a backwards slide of 1 or 2 - * to stall the OS clock so we can use an rtc to track a not so - * stable system clock. + * We assume a small negative warp in seconds is telling us + * that the clock is running too fast and we should stall. */ + if (slide == -1) + return; addtod: if (slide < 0) slide += 60; /* Seconds wrapped */