setting a c++ application to use maximum CPU usage, in the code

Go To StackoverFlow.com

0

I developed a program in c++ and when I run it in windows XP it uses all the available CPU to 100% of usage but when I run the application in windows 7 the app could hardly makes it's way to 40% even by setting the task to real-time or high priority one in taskbar is there a way that I could force the OS to let my application use maximum available CPU like what was in winXP in my code. I mean something like APIs or a library.

2012-04-04 21:28
by AMCoded
if your application is single threaded and the system has multiple CPUs, you will not see the total CPU go up to 100%. For example, if you have 4 cores, and your program is utilizing 100% of one of them, Windows will report CPU utilization at somewhere under 25% - MK. 2012-04-04 21:30
It's fairly nonsensical to strive to make your app use 100% of the CPU. That's not actually a metric you want to see. If you really want to fix the problem, you should try and figure out why it's spinning so many cycles on XP - Cody Gray 2012-04-05 02:21
@CodyGray if it is a CPU intensive application which does calculations only and no IO you do want to see it using 100% of CPU - MK. 2012-04-05 12:44


3

This is more than likely due to you having more than one core. In order to use 100% of your CPU you may need to have multiple threads created.

2012-04-04 21:30
by josephthomas


0

If your app is using any kind of IO, and that IO is messed up in XP (bad driver and/or something else), that might be causing your app to spin the CPU entirely.

7 is maybe better optimized in such areas, so it frees the CPU until slow (disk, network) stuff is completed.

2012-04-04 21:36
by Daniel Mošmondor


0

Also depending on what this thread is doing and how often it spends time off the processor (Sleep, object waits) can be a factor, but MK pretty much summed it up for you. You could also have a look here:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686277%28v=vs.85%29.aspx

2012-04-05 02:07
by everdox
Ads