alisha
alisha

Reputation: 1

Why does one core execute more than its share of instructions?

I have a C program (graphics benchamrk) that runs on a MIPS processor simulator(I'm looking to graph some performance characteristics). The processor has 8 cores but it seems like core 0 is executing more than its fair share of instructions. The benchmark is multithreaded with the work exactly distributed between the threads. Why could it be that core 0 happens to run about between 1/4 and half the instructions even though it is multithreaded on a 8 core processor?

What are some possible reasons this could be happening?

Upvotes: 0

Views: 636

Answers (2)

John Zwinck
John Zwinck

Reputation: 249642

Most application workloads involve some number of system calls, which could block (e.g. for I/O). It's likely that your threads spend some amount of time blocked, and the scheduler simply runs them on the first available core. In an extreme case, if you have N threads but each is able to do work only 1/N of the time, a single core is sufficient to service the entire workload.

You could use pthread_setaffinity_np to assign each thread to a specific core, then see what happens.

Upvotes: 2

user3629249
user3629249

Reputation: 16550

You did not mention which OS you are using.

However, most of the code in most OSs is still written for a single core CPU.

Therefore, the OS will not try to evenly distribute the processes over the array of cores.

When there are multiple cores available, most OSs start a process on the first core that is available (and a blocked process leaves the related core available.)

As an example, on my system (a 4 core amd-64) running ubuntu linux 14.04, the CPUs are usually less than 1 percent busy, So everything could run on a single core.

There must be lots of applications running like videos and background long running applications, with several windows open to show much real activity on other than the first core.

Upvotes: 0

Related Questions