www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/19/20:10:46

From: Engard Ferenc <s9008eng AT hszk DOT bme DOT hu>
Newsgroups: comp.os.msdos.djgpp
Subject: timing with empty loops -- small green ufo-s?
Date: Sat, 20 Feb 1999 02:04:52 +0100
Organization: Technical University of Budapest
Lines: 45
Message-ID: <Pine.GSO.4.10.9902200203130.13250-100000@ural2>
NNTP-Posting-Host: ural2.hszk.bme.hu
Mime-Version: 1.0
X-Trace: goliat.eik.bme.hu 919472694 4296 152.66.130.2 (20 Feb 1999 01:04:54 GMT)
X-Complaints-To: abuse AT news DOT bme DOT hu
NNTP-Posting-Date: 20 Feb 1999 01:04:54 GMT
X-Sender: s9008eng AT ural2
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi all,

It's a rather un-answerable question without further info, but I try
it...

My program does it's timing with empty loop:

void do_delay (unsigned long i)
{ while(i--) ; }

The calibration is nearly the same as the linux-kernel bogomips-computing
(actually, I have copied it from there... :-)  It was ran quite good,
at least for a day. And after a new compilation, it started to behave
strangely: the timings were half or double of the needed speed. My
loops_per_second variable sometimes changed appropriately the
speed-change, sometimes not. And the most strange is, that I can it
reproduce by inserting something (for example, a printf()-call) to a
totally different part of my program (which is runs later...)! I have
only one guess: maybe it depends on something word-boundaries... :-O
But basically, I am helpless. It is quite interesting that when my
loops_per_sec var also changed, it was exactly the half of the
'original' value. I don't think it is a programming mistake; I have
read it many times, and as I mentioned, can be triggered with
modifying indifferent parts of the program. If somebody is really
interested in, I can send her/him the whole program (it's small),
with the infos how to reveal the mistake (at least, on my computer).

Anybody tried to work with timings like this? I control a stepping
motor for a labor-automate, and if the program crashes during the
work, it would be cost much... So far, the program's behaviour
changed only after recompile, but who knows...? :-((

The program runs now on an AMD K6-266, 64MB RAM, ms-dos, no disk
activity (e.g. no smartdrv speaks here), -O1 optimization.

Thanks:
Circum

PS: Please cc. the answers to the mailto:s-fery AT kkt DOT sote DOT hu address too!

 __  @
/  \    _   _                                           Engard Ferenc
l    | ( \ /  | | (\/)                      mailto:s-fery AT kkt DOT sote DOT hu
\__/ | |   \_ \_/ I  I                    http://pons.sote.hu/~s-fery

- Raw text -


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