Short answer: you do not control it explicitly. The system runs several threads on several cores. Which core is loaded with which thread at each thread time spice is decided by the system threading scheduler.
However, there are ways to affect this behavior programmatically.
Remember, in almost all cases this is not recommended! The cases when it can help are very rare.
See the following Windows API:
GetThreadAffinityMask
/
SetThreadAffinityMask
,
GetProcessAffinityMask
/
SetProcessAffinityMask
and
SetThreadIdealProcessor
.
General information on thread affinity:
http://en.wikipedia.org/wiki/Processor_affinity[
^],
see also this discussion:
The perils of thread affinity:
http://www.bluebytesoftware.com/blog/PermaLink,guid,8c2fed10-75b2-416b-aabc-c18ce8fe2ed4.aspx[
^].
On MSDN, start here:
http://msdn.microsoft.com/en-us/library/ms685096(v=VS.85).aspx[
^],
http://msdn.microsoft.com/en-us/library/ms684251(v=vs.85).aspx[
^].
Again, don't interfere in thread/process affinity unless you know exactly what are you doing!
(I know just one case when modification of affinity can be helpful: working with standard hardware (typically industrial) which is "bad" in the sense that it requires extensive polling as interrupt-driven operation is node accessible via API; in this case it is beneficial to dedicate on code to some threads serving these "bad" parts of equipment, which makes other threads' timing to be more predictable.)
[EDIT]
Parallel computing is a big topic which goes well above the usage of CPU/cores.
For approaches to parallel computing, see:
http://technet.microsoft.com/en-us/library/ff919485(v=ws.10).aspx[
^],
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=f9d74066-0dfd-4a38-9bad-bff5e15c9629[
^],
http://academic.research.microsoft.com/Publication/1693102/on-task-mapping-optimization-for-parallel-decoding-of-low-density-parity-check-codes-on[
^].
It will give you the idea on what's involved. Do your research, find some more articles.
Start with:
http://en.wikipedia.org/wiki/Parallel_computing[
^].
—SA