HiveBrain v1.2.0
Get Started
← Back to all entries
gotchaMinor

Why does the operating system switch an active process to different cores?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
whytheactiveprocesssystemcoresdifferentoperatingdoesswitch

Problem

When running a single-threaded application that is 'always busy', on a multi-core computer, modern operating systems will typically switch the process from one core to another from time to time. Even when the other cores are always idle.

Typically you can see 1 of 4 cores on a quad core processor at 100% load while the other cores are 0-1%. Once in a while, the active process will 'jump' to another core, now leaving the original core idle and utilizing 100% of another core.

Why does this happen?

Is it because the process was context-switched (even though other cores were idling)? Or is it because of thermal or power-related reasons? Something else?

Solution

Multitasking works like this: allow user process to execute for a little, then switch back to OS scheduler to be able to execute something else.

In multicore architectures, every core has equal opportuninty to acquire the process.

If you want to force your process execution on the selected core, this selection must be stored somewhere. There’s usually no reason to do that.

Context

StackExchange Computer Science Q#98715, answer score: 2

Revisions (0)

No revisions yet.