I need to control the use of my application processor to a certain limit. My application will work in Win XP, Vista, Win7 and Windows 8.
I tried to implement to get the current CPU usage of the processor and use the Sleep () method. (I used the GetProcessTimes & GetSystemTimes API)
pseudo code:
for(;;) { //Get the current process CPU Usage int cpuUsage = CalculateCPUUsage(); if(cpuUsage > 50) Sleep(10) else { //Project implementation code } }
Question:
Can I write an application to monitor CPU usage of the processor and whenever the CPU reaches an acceptable limit, stop the process and continue it.
Thanks in advance for your help.
Jchan source share