Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allocate more processor cycles to my program

I've been working on win32, c,c++ for a while. I code on visual studio. Most of the time I see system idle process uses more cpu utilization. Is there a way to allocate more processor cycles to my program to run it faster? I understand there might be limitations from i/o, in those cases this question doesn't make any sense. OR did i misunderstood the task manager numbers? I'm in a confusion, please help me out. And I want to do something in program itself, btw I will be happy if answers are specific to windows.

Thanks in advance ~calvin

like image 385
rplusg Avatar asked Dec 30 '22 03:12

rplusg


2 Answers

If your program it the only program that has something to do (not wait for IO), its thread will always be assigned to a processor core.

However, if you have a multi-core processor, and a single-threaded program, the CPU usage of your process displayed in the task manager will always be limited by 100/Ncores.

For example, if you have a quad-core machine, your process will be at 25% (using one core), and the idle process at around 75%. You can only additional CPU power by dividing your tasks into chunks that can be worked on by separate threads which will then be run on the idle cores.

like image 119
Timbo Avatar answered Dec 31 '22 16:12

Timbo


The idle process only "runs" when no other process needs to. If you want to use more CPU cycles, then use them.

like image 31
Alex Budovski Avatar answered Dec 31 '22 17:12

Alex Budovski