09 Sep 99 01:04, Leonard Erickson wrote to All:
LE> I've got a DOS program that I need to run that hogs the CPU. Setting
LE> idle sensitivity to 1 improves things greatly.
LE> But I've got the source, and I'd like to make it more multi-tassking
LE> friendly. It looks like it's in a polling loop when it's hogging the
LE> CPU (basicly it's waiting for me to hit a key).
What you'll want to do is add a delay. Under Virtual Pascal, it uses
DosSleep (under the new version of Virtual Pascal, I beleive it's
something like SysSleep). But Delay should be adequate.
Try;
Repeat
Do_Something else Delay(1);
until keypressed or ....
That should free some of your CPU cycles for you. Absolutely amazing
what a difference that delay statement works. While testing it out, I
created a program that was basically as you say above (repeat..until
keypressed) and the CPU was pegged at 100%. With the delay in there, it
dropped back down.
Play with the length of the delay and see what gets you the best
results. With DosSleep (VP) I found 1 to work the best. I think with
Delay (BP/TP), 2 was the magic number.
Stewart Honsberger,
blackdeath@tinys.oix.com
... Why did CNN cancel that cool "Desert Storm" show?
-!- GOPGP/2 v1.23
--- Msged/2 TE 05
600
* Origin: Blackdeath BBS - Private (1:229/604)
|