delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/13/14:59:43

From: tdu AT enter DOT net (Tim Updegrove)
Newsgroups: comp.os.msdos.djgpp
Subject: Algorithm for integer timing loop
Message-ID: <391da3c3.14389608@news.enter.net>
X-Newsreader: Forte Free Agent 1.11/32.235
Lines: 20
Date: Sat, 13 May 2000 19:13:26 GMT
NNTP-Posting-Host: 207.18.11.45
X-Complaints-To: Abuse Role <abuse AT enter DOT net>, We Care <abuse AT newsread DOT com>
X-Trace: newshog.newsread.com 958245206 207.18.11.45 (Sat, 13 May 2000 15:13:26 EDT)
NNTP-Posting-Date: Sat, 13 May 2000 15:13:26 EDT
Organization: ENTER.net (enter.net)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I'm still having negative values (upper 16 bits out of 32 bits become
0xffff) with uclock() in Windows 98 SE using version 2.03.  clock()
works but the poor resolution makes my polling program much too slow.
If someone can help out with uclock() that would be great.  Otherwise,
I'm thinking about using an integer increment loop to figure out how
long x increments took on the current machine.  I believe someone
recently posted an algorithm for such a timing loop but I can't find
it.  I'd appreciate any algorithms or tips for making the algorithm
machine and processor independent.

Is counting the number of increments in 55ms using clock() and then
calculating how long each increment takes sufficient?  Do I need to do
it over a greater period of time in case Windows runs something in the
background once in a while?

My ultimate goal is to poll for a memory mapped register to change
without constantly checking the register.  I need a delay function in
microseconds.

Any help would be much appreciated as always.  Thank-you.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019