You can make your threads run on specific cores, but in general you should let the OS take care of this. The operating system handles most of this automatically. If there are four threads in a quad-core system, the OS will schedule them on all four cores, unless you take action to prevent it. The OS will also do things like try to keep a separate thread running on the same core, instead of moving them for better performance, rather than scheduling two threads to run on the same hyper-threading kernel, if there are free kernels, etc. .
In addition, instead of creating new threads for work, you should use a thread pool. The system will scale it to the number of processors available in the system.
Windows Internals is a good book to describe how the Windows Scheduler works.
source share