Jon B wrote:
Hi There!
We have 2 processor server (Not dual core, actual seperate
processors).
Is it possible from .NET to force some threads to run on certain
processor (say on processor #2)? For instance, run UI stuffs on
processor #1 and run other background stuffs on processor #2.
Possible?
From Win32, you can do this using SetThreadAffinityMask.
The CLR processing model does not guarantee that a .NET thread corresponds
to a Win32 thread, but in practice they do, so you could probably P/Invoke
to SetThreadAffinityMask and get something that "works", but that could be
broken by the CLR in some future release when/if .NET threads are no longer
1:1 associated with Win32 threads.
If you're hosting your code in SQL Server, this may already be the case (I
think that feature was pulled before 2005 shipped, but I don't know for
sure).
Generally, messing with thread affinity is a bad idea - it rarely improves
the performance of your application and can do it serious harm.
-cd