Hard Light Productions Forums

Off-Topic Discussion => General Discussion => Topic started by: kasperl on March 20, 2005, 04:52:40 am

Title: Limiting a process's CPU usage in WinXP Home
Post by: kasperl on March 20, 2005, 04:52:40 am
I'm running a DOS app I wrote myself in QuickBasic under WinXP Home, and the thing will use 100% of the CPU when active, even if it's  just waiting. This is on a laptop with something like Cool&Quiet, but while running this app, the computer is cool nor quiet. I can use the computer normally if I lower the processes priority, but I was hoping for a way to limit the percentage of processor cycles that a process can use.

Any way to do this without switching to Linux?
Title: Limiting a process's CPU usage in WinXP Home
Post by: kasperl on March 20, 2005, 01:02:15 pm
Bumpage......

Any idea's at all?
Title: Limiting a process's CPU usage in WinXP Home
Post by: mrduckman on March 20, 2005, 01:26:54 pm
ah. a unix nice cmd :P
Title: Limiting a process's CPU usage in WinXP Home
Post by: mrduckman on March 20, 2005, 01:28:30 pm
Isn't a 'lower process priority" thing in the task manager process list?

If not, try Process Explorer.
Title: Limiting a process's CPU usage in WinXP Home
Post by: kasperl on March 21, 2005, 10:45:07 am
Prio won't help if there isn't anything else eating up the cycles.
Title: Limiting a process's CPU usage in WinXP Home
Post by: Taristin on March 21, 2005, 10:58:12 am
I dunno. My system Idle Process seems to use up all of my cycles. ;)
Title: Limiting a process's CPU usage in WinXP Home
Post by: kasperl on March 21, 2005, 11:18:36 am
That's percentage of used cycles you're seeing. You need to check 'prestations' (middle tab) (Dutch windows sucks), to see percentage CPU used.
Title: Limiting a process's CPU usage in WinXP Home
Post by: mrduckman on March 21, 2005, 06:45:02 pm
What does the qbasic program actually do?
It isn't waiting for an IO, is it? :p
Title: Limiting a process's CPU usage in WinXP Home
Post by: Scuddie on March 21, 2005, 07:15:22 pm
Actually, it is.

EDIT:  Couldnt tell if that was sarcasm, or mocking.  So it isnt my fault if I look like a jackass :p.
Title: Limiting a process's CPU usage in WinXP Home
Post by: mrduckman on March 21, 2005, 07:40:04 pm
AAAAAAHHHHH. Forget about renicing an IO process that is stuck. Kill it and debug.
Title: Limiting a process's CPU usage in WinXP Home
Post by: kasperl on March 22, 2005, 11:08:00 am
It is not stuck, it's waiting for me to think of the right answer.

(I use it to revise vocabulary and stuff. It'll output some word, and I have to give a translation, it'll check for correctness, ask the wrong answers again, all neatly randomized and stuff. It'lll even keep score.
If it's waiting for a keypress the system will damn nearly die, but if it's waiting for an input (terminated string), it'll just get the processor really hot.)

And little to no way for me to debug that code, I wrote it a few years ago, it's over 1100 lines, with only GOTO and the most basic loops. And no comments.
Title: Limiting a process's CPU usage in WinXP Home
Post by: mrduckman on March 22, 2005, 02:39:24 pm
It is odd that the program takes all the cpu if it's just waiting for an input.
Anyway, you could time the input and if n seconds passes, exit.
I believe it can be done.
Title: Limiting a process's CPU usage in WinXP Home
Post by: Odyssey on March 22, 2005, 04:07:23 pm
You could just limit the entire CPU by using something like SpeedswitchXP (http://www.diefer.de/speedswitchxp/), but that'd only work if other apps you're running at the same time don't need much processor power.
Title: Limiting a process's CPU usage in WinXP Home
Post by: kasperl on March 23, 2005, 06:17:39 am
Quote
Originally posted by mrduckman
It is odd that the program takes all the cpu if it's just waiting for an input.
Anyway, you could time the input and if n seconds passes, exit.
I believe it can be done.

1) It's made for DOS
2) I'm using the SLEEP command, meaning 'wait for a keypress, and the  continue'
3) It'd be bloody near impossible to use a timer there, since I need the user to confirm seeing the results.
4) AFAIK the thing goes like this:

while(keypress!=anything)
{get keypress;}

So yeah, it'd eat up a lot of juice.