How to keep a program from hogging the processor?
How to keep a program from hogging the processor?
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.
For any grievances posted above, I blame whoever is in charge . . .
- burger2227
- Veteran
- Posts: 2465
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
If he went to bed?
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
I anticipated a SLEEP kind of answer, but once you start something, ya gotta finish it!
Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
- Kiyotewolf
- Veteran
- Posts: 96
- Joined: Tue Apr 01, 2008 11:38 pm
Fixing your CPU
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.
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.
Banana phone! We need more lemon pledge. * exploding fist of iced tea! * I see your psycho cat and counter with a duck that has a broken leg, in a cast.
Re: If he went to bed?
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.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
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.
For any grievances posted above, I blame whoever is in charge . . .
- burger2227
- Veteran
- Posts: 2465
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Euler
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
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
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Code: Select all
do
sleep 25,1
loop
What you mean?I anticipated a SLEEP kind of answer, but once you start something, ya gotta finish it!