Re: [AD] General time-passed function

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


George Foot <george.foot@xxxxxxxxxx> writes:
> This is a subject that's come up before -- people wanting a general 
> record of time passing.  The standard answer is that they should 
> install a timer handler, and increase their own variable, I suppose. 

That's the standard way, but is certainly less than ideal for simply 
measuring time.

> However, if we make a dedicated function, it could offer better 
> accuracy than Allegro's timer callbacks. Under Linux and possibly other 
> Unixes you can get the time pretty accurately, and this is true to ms 
> resolution in Windows too AFAIK. Might this be worth adding?  It's a 
> fairly easy thing to do -- I can supply code for Linux and DOS box 
> under Windows (95/98 definitely).

I like the idea. The hairy bit is making this work in real DOS, with the 
variable-rate timers: that's why I never added this function before :-) 
Since the PIT rate keeps changing, it would need some careful 
instrumentation to keep track of what the timer controller was doing with 
it, and if this measurement is to be any more accurate than the interrupt 
rate (bearing in mind that the PIT rate can be as slow as 1/18.2 sec if 
no callbacks are requested), it also requires reading back elapsed time 
from the PIT, which opens up all sorts of fun questions about what 
happens if the timer expires while you are in the middle of reading it. 
I'm sure this can be done, but it isn't exactly my idea of fun :-)


-- 
Shawn Hargreaves - shawn@xxxxxxxxxx - http://www.talula.demon.co.uk/
"A binary is barely software: it's more like hardware on a floppy disk."



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/