Page 1 of 1

How to keep a program from hogging the processor?

Posted: Mon Mar 31, 2008 8:48 pm
by Mentat
I was just wondering how to run make FB programs in the back ground. Specifically, math intensive programs that run for extensive periods. I had to run one overnight because everything else was getting unresponsive or ridiculusly slow.

Posted: Tue Apr 01, 2008 3:54 pm
by BadMrBox
Add a sleep in your main loop too keep it from hoggin all the processor power.

Posted: Tue Apr 01, 2008 3:59 pm
by Mentat
Alright. Is there a way to directly ask for a fixed percentage? Such as constantly using 3%?

If he went to bed?

Posted: Tue Apr 01, 2008 11:34 pm
by burger2227
Am I missing something here? The program apparently ran for a long time. Sounds better than sitting there waiting for answers!

I anticipated a SLEEP kind of answer, but once you start something, ya gotta finish it!

Ted

Fixing your CPU

Posted: Tue Apr 01, 2008 11:51 pm
by Kiyotewolf
Tell your program to periodically take a coffee break.

Your program will only hog CPU cycles if it constantly requests access to something via IRQ, DMA, or the FPU (486+1) math co-processor chip.

That means.. make it do something stupid like twirl a cursor..

- / | \ - / | \ .. or do a null loop.. something long enough that the CPU will not try to optimise it and kill the whole point of slowing down.. or something creative that is just plain mundane.

Simple.

Check against clock cycles or whatever timer you can find to interrupt your processing that way.

Re: If he went to bed?

Posted: Wed Apr 02, 2008 6:29 am
by Mentat
burger2227 wrote:Am I missing something here? The program apparently ran for a long time. Sounds better than sitting there waiting for answers!

I anticipated a SLEEP kind of answer, but once you start something, ya gotta finish it!

Ted
These problems can run for a long time. So, I want to be able to use the computer in the mean time for other things, such as other problems.

Such as: Find the product of the pythagorean triple that sums up to 1000.
Ohhhhhhhh......I'm an idiot. Never mind that, but some of the other problems do take some time. I just want answers. And my question on how to keep it quiet was answered well.

They're from the Euler project, if that means anything to you.

Euler

Posted: Wed Apr 02, 2008 1:53 pm
by burger2227
OK, a timed SLEEP can allow the program to share the processor. Even with Windows. The best scenario would be to be in pure DOS.

SCREEN 0 is probably the best option to run 2 QB programs at once.

I saw the Euler project before, but I figured that it was a waste of time. Have you learned anything? If you are happy then I am too!

Have fun,

Ted

Posted: Wed Apr 02, 2008 4:26 pm
by BadMrBox

Code: Select all

do
sleep 25,1
loop 
Will make your program wait for 25ms every cycle making it quite much less cpu craving.
I anticipated a SLEEP kind of answer, but once you start something, ya gotta finish it!
What you mean?