From: sandmann AT clio DOT rice DOT edu (Charles Sandmann) Message-Id: <10303101722.AA20067@clio.rice.edu> Subject: Re: Example uclock() code To: djgpp-workers AT delorie DOT com Date: Mon, 10 Mar 2003 11:22:03 -0600 (CST) In-Reply-To: <0eec01c2e70c$1f78cef0$0600000a@broadpark.no> from "Gisle Vanem" at Mar 10, 2003 02:51:17 PM X-Mailer: ELM [version 2.5 PL2] Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > > + while ( (tics = _farnspeekl(0x46c)) == otics); > > A debugger will propably hang indefinitely here. Maybe add > a __asm__("sti"). Debuggers should not (?), but you can't CTRL-C out of it - it must complete before you get the signal. > Instead of counting the TSC over CALIBRATION_TICS, it's > better to *average* the TSC over CALIBRATION_TICS samples. > This because of the jitter in the while-wait loops. It doesn't > (as you said in original message) really wait N*ticks. If the tics in the middle are used for both start and end, you get the same answer (it averages out). If you don't, and get a new start tic each time - then it takes twice as long elapsed (the current 5 TIC wait can take up to 6 tics waiting for the first tic roll-over). If you did 5 calibrations of 1 TIC long it would typically take 10 tics. It appears a single calibration of 10 tics would be more accurate than averaging 5 samples, based on the error distributions. > BTW. the accuracy will depend on DOS-box setting of > "Program | Advanced | Emulation of timekeeper" (or what > ever it's called in English Windows). Reading the PIT is > not very accurate even when set on. I can't find such a setting on Windows 2000. The PIT is completely unreliable and uncoordinated with the timer tic (usually... that's a long story) so I'm calibrating using the timer tic alone (which is also flakey ...).