Windows – Single-threaded application being balanced across CPU cores

central-processing-unitcpu-usagemulti-threadingwindows

Is there an easy way to check whether a certain single-threaded application is being balanced across CPU cores by Windows?

I have already tried Process Explorer but I could not find a way to read it out, if possible in the first place.

The reason I am wanting to know this, is because I understand that not all single-threaded applications get balanced, but rather stick to 1 core instead.

Best Answer

"Balanced" is a relative term.

Moving a process between cores can invalidate certain optimizations (shared cache helps, but CPU registers are per core still), so if your OS is "balancing" a process by moving it around it may be causing more harm than good.
For highly optimized (often hand-crafted assembly) programs it can take longer to restore register states than to just let the process keep one CPU all to itself.

On the other hand if a CPU-Bound process doesn't use the registers heavily and doesn't so much care if they have to be reloaded, and if there is a lot of contention for the CPU, moving it around to whatever processor is available might improve performance.

What I'm getting at here is that for a single-threaded process You don't care -- Trust your operating system's scheduler to do the Right Thing (it really is smarter than you about this sort of thing).


For multithreaded processes the same logic applies, just multiple times: Do you care WHERE the threads are running as long as they're getting the CPU time they need and running quickly?
My guess is no.


To answer the question you asked: Because you really shouldn't care I don't think it's possible.

There's certainly not an easy way to get at this in Windows (the task manager and Process Explorer don't expose it anyway). You could look in to Power Shell scripting, but I don't believe there's a way to do it there either...