[comp.sys.ibm.pc] wall-time creep under MS-DOS?

zeus@zapodid.aero.org (Dave Suess) (04/14/89)

I have a realtime application using a PC clone under MS-DOS -- it uses
the 18 Hz interrupt to run a closed-loop servo.  The software is in C,
and part of it needs (and displays) local time (using the appropriate
compiler library calls -- Turbo C, in this case).

After a few weeks running, the date advances by several days!  Is this
related to interrupts, system calls, or what?  I can't duplicate it on a
more recent system, and a colleague tells me he's seen this problem written
up somewhere... I'd appreciate any pointers anyone can give me (the end 
result will be saving $$ for taxpayers, if that's any excuse).
			Dave Suess	zeus@aerospace.aero.org
					...!trwrb!aero!zeus

raymond@ptolemy.arc.nasa.gov (Eric A. Raymond) (04/18/89)

In article <49479@aerospace.AERO.ORG> zeus@zapodid.UUCP (Dave Suess) writes:
>I have a realtime application using a PC clone under MS-DOS -- it uses
>the 18 Hz interrupt to run a closed-loop servo.  The software is in C,

>After a few weeks running, the date advances by several days!  Is this

You've probably replaced the original clock interrupt with your own
routine and/or changed the frequency at which the interrupt is called.

For the former, call the original interrupt routine sometime during
your new interrupt (chain it).

For the latter, put some logic in your routine such that the original
interrupt routine gets service at its original rate. (i.e. If you
changed the timer to be four times faster, count to four and then call
the interrupt).

--
-- 
Eric A. Raymond  (raymond@ptolemy.arc.nasa.gov)
G7 C7 G7 G#7 G7 G+13 C7 GM7 Am7 Bm7 Bd7 Am7 C7 Do13 G7 C7 G7 D+13: Elmore James

cs3b3aj@maccs.McMaster.CA (Stephen M. Dunn) (04/21/89)

In article <49479@aerospace.AERO.ORG> zeus@zapodid.UUCP (Dave Suess) writes:
>I have a realtime application using a PC clone under MS-DOS -- it uses
>the 18 Hz interrupt to run a closed-loop servo.  The software is in C,
>and part of it needs (and displays) local time (using the appropriate
>compiler library calls -- Turbo C, in this case).
>
>After a few weeks running, the date advances by several days!  Is this

   Are you using the number 18 as the clock frequency?  If so, that's
probably your problem ... it's not actually 18 Hz, it's more like 18.2
(as near as I can figure it, it's 18.215 Hz; maybe one of the IBM Tech
Refs is more precise).

   This might be your problem ... other possible causes include the
possibility that the crystal running your machine's clock isn't the
precise frequency you expect it to be; however, you'd think it would
be more accurate than advancing several days every few weeks.

   Hope this helps.
-- 
======================================================================
! Stephen M. Dunn, cs3b3aj@maccs.McMaster.CA ! DISCLAIMER:           !
! This space left unintentionally blank - vi ! I'm only an undergrad !
======================================================================