Tuesday, 11 June 2013

CPU Hyper-threading

Warning - this post is basic at best and potentially inaccurate at worst... but it's how I understand Hyper-threading so I'm writing it down for my own benefit...

A common set up you might see on a fairly large piece of hardware would be as follows ...
- 2 sockets
- 16 cores (8 cores per socket)
- 32 virtual CPU's (Hyperthreading provides 2 "threads" per core and the OS see's each thread as a CPU which means 16 cores shows up as 32 CPU's)

Starting with sockets, these are - as you would imagine - the physical sockets in the circuit board that the CPU chips plug into

Then we have cores... these are real layers of silicon inside those chips that are capable of processing independently, i.e if a CPU has 8 cores, it's like having 8 separate CPU's, all of them can process stuff independently. I think there are pro's and cons to mounting 8 separate CPU's on one chip .. at a guess I think these need to share registers (which would be a negative thing) and another guess would be that they can communicate more quickly with each other as they don't need to talk over the bus (this would be a positive thing)

Now for the Logical / Virtual CPU's .. this means that each core can accept jobs / tasks on 2 "queues". The OS sees these "queues" as separate CPU's and can schedule work for them accordingly. I like to think of these queues as conveyer belts on which work can be placed. At the end of each conveyer belt is a worker (imagine a person who's job it is to process the tasks that arrive on the 2 conveyer belts). This worker represents the CPU Core and it's capable of processing one task at a time. Imagine if this worker was working on a task which needed to wait for data from a database halfway through processing. What would the worker (i.e the Core) do at this point?.. stand around whistling, twiddling it's thumbs?... the answer is.. it would turn to the other conveyer belt and start processing a task from there. At some point the original task would retrieve all of the data it was waiting for and notify the worker (Core) that it was ready to continue being processed. Not sure how that scheduling works but in a nutshell this is my understanding of Hyper-threading.

No comments:

Post a Comment