Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
If the operating system schedules multiple threads against a hyper-threaded CPU, the CLR automatically takes advantage of this. This is certainly the case for new versions of the OS like Windows Server 2003.
Also, the CLR did work to properly spin on a hyper threaded system. If you are writing your own spinlocks in managed code, be sure to use Thread.SpinWait so that you get the same benefits.
We also tune subsystems like the scalable server GC so that they make sensible decisions for hyper threading.
Comments
- Anonymous
April 17, 2003
Hi Chris,(Wow, i'm very impressed by dropping a comment on one of your posts)It's almost a question, in fact. I was looking for infos about hyperthreading yesterday, and I found a page on Intel's web site that says that both versions of XP support hyperthreading (with a compatible CPU, of course).Link: http://www.intel.com/support/platform/ht/os.htmSo, does the CLR take advantage of an HT CPU on XP too?/Christophe - Anonymous
April 18, 2003
Yes it does. - Anonymous
May 01, 2003
Chris, thanks for mentioning the SpinWait method. We've talked about this a few times in the past, but this never came up. I'll use it in a few of my test cases. Perhaps I should mention this in my reliability document? - Anonymous
January 31, 2004
The .NET 1.0 SDK documentation for Thread.SpinWait is not exactly illuminating:
Thread.SpinWait Method [C#]: Causes a thread to wait the number of times defined by the iterations parameter.
What exactly does Thread.SpinWait do? - Anonymous
February 01, 2004
Assume the usual caveats about how implementations are subject to change, etc.
In a loop, we do a 'rep nop' instruction for the number of iterations you specify. This instruction is the approved way to create a yield from one logical CPU to another logical CPU of a hyper-threaded physical CPU.