JO SeongGng
JO SeongGng

Reputation: 567

Why a single-threaded application occupies multi cores and limits cpu usage

I use delphi xe6 and dual cores.

In my former question many have answered to use multi threads to disperse core load. Thanks.

I coded an over loaded sample. In this sample I didn't use multi threads but the load disperses.

Please let me know the reason the load disperses without multi-thread coding and the cpu usage is limited around 50% during the calculation?

And if I use tParallel.For in xe7 the performance(specifically the cpu usage) will be better?

Thanks always.

enter image description here

Upvotes: 0

Views: 1373

Answers (1)

Rob Kennedy
Rob Kennedy

Reputation: 163357

If you have two cores and a single-threaded program that is CPU-bound, then you should expect to see the average CPU usage for your system somewhere around 50%, representing 100% divided by 2 CPUs.

I don't read the language of the UI shown in your picture, so I can't read the labels, but it appears to illustrate just what I described. The bottom two graphs, when averaged, yield the top graph. Your program might not be running exclusively on a single CPU; the OS is at liberty to schedule your program to run on either core for each time slice.

Your code doesn't parallelize well; it still updates a single shared resource in the window caption. You should expect roughly equal to worse performance when run in parallel: You'll see twice as much CPU usage, but for about half as much time. It will probably skew worse, though, because of the contention over the window caption from multiple threads.

Upvotes: 4

Related Questions