Multithreading implementation -- assign thread to a specific processor?

  • Thread starter Thread starter Rob R. Ainscough
  • Start date Start date
R

Rob R. Ainscough

Is it possible to assign threads to a specific CPU ID? I'm attempting to
provide performance benefits for 2 and 4 CPU systems and would like to
assign specific threads to a processor, is this possible with .NET? Can't
seem to find anything that would not include such support? API (aka
unmanaged) solution?

Thanks, Rob.
 
Is it possible to assign threads to a specific CPU ID? I'm attempting to
provide performance benefits for 2 and 4 CPU systems and would like to
assign specific threads to a processor, is this possible with .NET? Can't
seem to find anything that would not include such support? API (aka
unmanaged) solution?

Thanks, Rob.

Maybe System.Thread.ProcessorAffinity?
 
Rob R. Ainscough said:
Is it possible to assign threads to a specific CPU ID? I'm attempting to
provide performance benefits for 2 and 4 CPU systems and would like to
assign specific threads to a processor, is this possible with .NET?

(Based on a post by Thomas Scheidegger [MVP].)

'Process.ProcessorAffinity'
<URL:http://msdn.microsoft.com/library/e...nosticsProcessClassProcessorAffinityTopic.asp>

'ProcessThread.ProcessorAffinity'
<URL:http://msdn.microsoft.com/library/e...sProcessThreadClassProcessorAffinityTopic.asp>

'ProcessThread.IdealProcessor'
<URL:http://msdn.microsoft.com/library/e...ticsProcessThreadClassIdealProcessorTopic.asp>

Determining the number of processors:

\\\
Imports System
..
..
..
.... = Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS")
///

..NET 2.0: 'Environment.ProcessorCount'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top