|
-
Dec 11th, 2003, 02:12 AM
#1
Thread Starter
Fanatic Member
Set CPU usage limit on a particular app (Tough
Experts,
got any idea of how to limit the cpu usage by a particular program ... say for example ... i would like to make the program utilize 50 % of the CPU processing ................... whatever the program does, it will definitely not gonna use the cpu processing power over 50%.....
-
Dec 11th, 2003, 03:01 AM
#2
Fanatic Member
I've an idea that almost does what u want. This idea suits well
only if ur codes are in a loop.
So, first, u need to collaborate the global CPU usage reading with
ur app. Say, u check the CPU usage for 3 seconds, then get the
average out of it. Say, it's about 2%.
Then u run ur code loop, at the same time, check CPU usage. If it
exceeds 52%(50%+2%), stop it, and check how many loops have
been executed per second. Say, 100 loops per second.
After that, everytime u execute ur loop, put some conditional
codes that always check if the loops executed per second has
exceeded 100 loops per second. If it is, then execute Sleep
API with a value of 0 passed to it. By passing a zero value, u ask
the program to give the remaining timeslice to other threads.
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline 
So I consider all those working engineers sad people
VB FTP class
3 page PHP crash course
Crash Course on DX9 Managed with VB.NET covering basics till terrain creation
-
Dec 11th, 2003, 03:22 AM
#3
Thread Starter
Fanatic Member
okay ... cool idea. /
but my case is that (its not a fast loop). it is a timer loop... depending on the miliseconds value
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|