There's really no easy way to tell, but it's hard to see how that would be useful information anyway. If it's the only thing running, you can use the task manager to look at the load on each core.
–
David SchwartzJul 27 '12 at 0:18

1

Applications must be written to take advantage of multiple cores. Since the programmer has to take care of identifying which parts of the program can be split and run concurrently and then has to deal with maintaining locks on data, many developers simply don't write their apps in this way. You said not all single-threaded applications get balanced. In fact, NO single-threaded applications can be split among cores. The application must be multi-threaded. This is a great question though because I can't seem to find an answer...
–
Paul AckermanJul 27 '12 at 0:23

The programmer can lock an application to a particular CPU core if they want to, but there's rarely a good reason to do so.
–
Harry JohnstonJul 27 '12 at 2:18

1 Answer
1

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...

I should not care as long as it gets the CPU time it needs, but if I am planning to run multiple instances of this single-threaded application, would it not mean that only one core gets to deal with all of it? If so, I would like to assign a specific core to each of them. Would it not be a shame to have a beast of a CPU but only to be able to use one core?
–
XenJul 27 '12 at 15:09

@Xen A single threaded app won't limit all instances of itself to a single thread, so you don't need to worry. If you want to try to control it manually anyway, you can use Set Affinity in Task Manager. If you fire up a bunch of instances, you can set the affinity of each process (assuming multiple instances spawn multiple processes) to an individual core, if you want. That said, voretaq7's right that the OS scheduler is going to do a better job than you will of getting the application the CPU it needs.
–
HopelessN00b♦Jul 27 '12 at 21:00