Using Dual / Quad Core Technology

In C #, when I create a new thread and execute a process in that thread, is there a way to assign it to a specific kernel? Or does the operating system handle all this automatically? I wrote a multi-threaded application, and I just want to be sure that it is optimized for working with two / four cores.

thanks

+4
source share
4 answers

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.

+7
source

For your question, you are likely to be interested in expanding the .NET 4 parallel task library (TPL). Take a look at the article .

+5
source

This post shows how to adjust the affinity of a processor to a specific process thread. You can use this property to restrict the binding of a thread to a specific processor or processor set.

+1
source

Multiple threads typically run on multiple cores or processors. By default, this is Windows Manager, which assigns threads to processors.

0
source

All Articles