December 16th, 2005

When hyperthreading is enabled, all the processors are virtual

A common problem when answering technical questions is that people sometimes ask a question that can’t or shouldn’t be answered because it is based upon a misunderstanding. What’s particularly frustrating is when they insist that you answer their question as posed, even when you try to explain to them that their question is itself flawed.

It’s as if somebody asked you the question, “Do I have to use the remote control to lock my kangaroo?” You could answer the question literally (“No”), but the person asking the question would walk away with the wrong conclusion (“Wow, kangaroos are self-locking!”). Robert Flaming recalls a similar analogy I made with balsa wood and nails.

Here’s an example of a question that betrays misunderstanding.

I just enabled hyperthreading on my dual-Xenon machine, and Task Manager now shows four processors instead of two. Which of them are the physical processors and which are the virtual ones?

When you turn on hyperthreading, each individual physical processor acts as if it were two virtual processors. From Task Manager’s point of view, the computer has four virtual processors. The two virtual processors associated with each physical processor are completely equivalent. It’s not like one is physical and one is virtual. They are both virtual and compete equally for a share of the one physical CPU. When you set processor affinities, you set them to virtual processors.

To find out which virtual processors are associated with the same physical processor, you can call the GetLogicalProcessorInformation function.

Topics
Other

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.

Feedback