Originally posted by: VirtualLarry
Well, like I said, they did say the MPS Uniprocessor x86 HAL, I don't have experience with the MP HAL. It's possible that the idle loop is different for the MP HAL, but I would be surprised if it was just sitting in a spin-loop,
I apologize, I didn't make myself very clear before: the idle loop does more than simply HLT, but I didn't mean to imply that it simply "spins" in Win2k without halting. Win2k *does* issue a HLT eventually.
The "spinning" behavior to which I was referring is a result of the system timer firing, sending an interrupt that starts the idle loop all over again (unless another thread has been scheduled). This is precisely the type of loop that the Intel article was warning against: the spinning code steals cycles from the running threads. The XP Idle Loop has been specifically rewritten to mitigate this spin contention by issuing a HLT whenever possible.
If the SysInternals guys said that the Idle loop merely executes a HLT instruction, they are mistaken (even in the uniprocessor case). There is a good deal of housekeeping work that is performed in the Idle Loop too.
The idle loop in Win2k executes an algorithm something like the following:
1) obtain a mutex for the scheduling data structure
2) check to see if anything is ready to run
3) check to see if there are any DPCs to run
4) HLT
5) (system timer interrupt fires)
6) goto 1
Note that I have not personally examined the MPS HAL assembly code for XP and Win2k directly to see what exact changes they were able to make to execute the HLT more frequently in XP than in Win2k.
I did, however, find a publicly available direct reference to what I'm describing: You can refer to Section 5.2 of
Windows Support for Hyper-threading Technology.
You can also Google for "Windows 2000 hyper-threading halt" which seems to turn up a few other links.
I trust the SysInternals guys pretty well, they seem to know as much or more than MS in some particular areas (aside from the OS designers themselves).
MS is a huge company, so it is no coincidence that you will encounter people who don't know much about the NT kernel. But trust me, most people in the Windows division know what they're talking about.
I suppose I could disassemble the code for the scheduler and take a look myself, but I don't have an SMP system to test on. I don't suppose that you have publically-available source-code for the HAL's scheduler, do you?
I do have full Windows source code access, but I obviously can't provide any confidential information (including algorithms or instructions) or make direct comments about the actual source code.