Path: utzoo!utgpu!jarvis.csri.toronto.edu!ists!yunexus!maccs!cs4g6ag From: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) Newsgroups: comp.sys.ibm.pc Subject: Re: getting the time Message-ID: <256838CD.7791@maccs.dcss.mcmaster.ca> Date: 20 Nov 89 17:47:56 GMT References: <17118@netnews.upenn.edu> Reply-To: cs4g6ag@maccs.dcss.mcmaster.ca (Stephen M. Dunn) Organization: McMaster University, Hamilton, Ontario Lines: 34 In article <17118@netnews.upenn.edu> hardt@linc.cis.upenn.edu (Dan Hardt) writes: $A friend needs to read the time for a real-time application. $We tried using some Microsoft C functions for reading the $clock. The functions returned the time down to the hundredth $of a second -- but they don't seem to notice any change in the $time less than 5/100 of a second or so. If we have a loop which $continually checks the time, its values are ,eg, $ 0,0,0,0,5,5,5,5,5,11,11,11,etc $Why is this? Any way to get a more fine-grained access to the time? This is because the clock ticks in the PC run at approximately 18.2 Hz, or roughly .055 seconds apart. If you're using the system clock, accessed through a DOS call (which is how every compiler I've seen does it), that's the best resolution you can get. In order to get a more fine-grained clock, there are a couple of ways to do it: 1. Find one of the timers that isn't used for anything and program it to run at whatever speed you want (you'd have to check the IBM tech ref for this info, unless someone else can fill you in) 2. Speed up the 18.2 Hz clock to some multiple of that speed, insert your own code into the clock tick (BEFORE DOS's own code, of course!) which a) updates your counter once per fast tick b) calls the normal DOS clock routine once every n clock ticks, where n is your speedup factor. Hope this helps! -- Stephen M. Dunn cs4g6ag@maccs.dcss.mcmaster.ca = "\nI'm only an undergraduate!!!\n"; **************************************************************************** They say the best in life is free // but if you don't pay then you don't eat