[fpc-pascal]dos approx delay fn that releases cpu

Lee, John LeeJ at logica.com
Tue May 8 13:35:48 CEST 2001


Tried this under w95 & it works ie gives delay, but hogs the cpu! So still
looking for way to do fpc dos delay, that works in w2000, NT & w9x...

Current status is that my original program works ok for w9x (ie gives delay
and releases cpu), but we do not have a way to do this in w2000/NT... Any
more ideas? What about using the get & put interupt vector instructions to
change the timer interupt to an _internal_ routine which counts clock
interupts and doing a dos idle in between (believe that releases cpu in
NT/w2000???).  Anyone know exactly the  the code for that would look...? 

We could then check whether it's w9x & either execute my original, or the
new w2000/nt code., and we'd have a general purpose  dos calleable approx
delay that releases cpu... John

----Original Message-----
From: Thomas Schatzl [mailto:tom_at_work at yline.com]
Sent: Saturday, May 05, 2001 12:53
To: fpc-pascal at deadlock.et.tudelft.nl
Subject: Re: [fpc-pascal]dos approx delay fn that releases cpu


Hi again,

> > > Stockton's site) that works in tp (under win95 and on win2000)
> > > and releases cpu time. Is there an equivalent that'll work in fpc?
> > It may be possible to add this to the go32v2 crt unit's
> > current delay function (simply add a "hlt" in both the initdelay and
> > delay functions internal loop). It might cause a loss of accuracy
> > though...
>
>  _If_ we decide to add something similar to the delay unit, we should
> replace the halt instruction with the DOS idle call, because that many
TSRs
> use this one under plain DOS and it's still supported under Wxx to lower
the
> CPU load.

I did some tests with W2k and it seems as if the DOS idle call is not
supported anymore (because it's not DOS the program is running). It might be
some programming mistake too though:

{delay of n ticks releasing cpu}
uses go32;

var
 timer : byte absolute $0040:$006C ;
var
 r : registers;

procedure dlay(n : integer) ;
const t : byte = 0 { static! saves some stack space } ;
begin
 while n > 0 do begin
         t := timer ;
         repeat
        // call DOS idle interrupt (my IR list from Ralf Brown says it's int
28h)
        // since the register structures' ss:sp is zero on entry the dpmi
host
        // automatically provides a real mode stack
          realintr($28, r);
         until timer<>t ;
         Dec(n) ;
        end;
end;

begin
// wait approx. 5 secs
 dlay(18*5);
end.

This program drives the cpu usage meter to 100% here.... it seems to me that
the DOS idle call is just a more elaborate way to accomplish a 'nop'.

Could anyone try with W9x ?

Btw, isn't the accuracy of the delay quite bad when using the timer IR ?
Because It only changes ~18.2 times per second giving a resolution of ~54
ms. The variance of the result is also quite high; +- a full timer tick
depending on the spot within a timer tick the timer is read first....
Although it's usually not that serious if the default delay is off a few ms
this is imho a little bit too much.

Regards,
    Thomas


_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal




More information about the fpc-pascal mailing list