CPU Restriction

  • Thread starter Thread starter Ashish
  • Start date Start date
A

Ashish

Hi Friends,
Is there any way I can restrict a thread to be processed by only (one / )
certain number of CPUs in a multi CPU machine in .net framework ? I found
the equivalent functions in win32 api (SetThreadIdealProcessor and
GetSystemInfo). Problem is I want to use threads from within .NET framework
and not the old MFC way..
Thanks
Ashish
 
Ashish said:
Is there any way I can restrict a thread to be processed by only (one
/ ) certain number of CPUs in a multi CPU machine in .net framework ?
I found the equivalent functions in win32 api (SetThreadIdealProcessor
and GetSystemInfo). Problem is I want to use threads from within .NET
framework and not the old MFC way..

In .NET you can use:
"System.Diagnostics.ProcessThread"-class and the member "ProcessorAffinity"


By the way:
"SetThreadIdealProcessor" does NOT resrict the thread to the specified
processor! It only tells the scheduler to use this processor as often as
possible!!!

The correct API is "SetThreadAffinityMask"



--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/useritems/leakfinder.asp
 
Back
Top