CPU Restriction

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
 
J

Jochen Kalmbach

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
 

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

Top