Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relation between CPU's hyperthreading and OS's context switch?

Hyperthreading of a cpu core means the core can be treated as logically two or more logical/virtual cpu cores to run multiple processes.

An operating system also provides concurrency programming, by scheduling and context switch.

Do the two do the same thing, i.e. support concurrency programming?

What are their relations? For example, does OS's concurrency require the cpu core to provide hyperthreading, or vice versa?

Thanks.

like image 970
Tim Avatar asked Dec 08 '25 22:12

Tim


1 Answers

Hyper threading requires additional hardware support.

  • In a context switch you have to remove all information from the hardware and load the information for the other process in.

  • In case of HT you have duplicated hardware units which have the information of other process pre-loaded so that the switch is very swift.

So for a core that is hyper threaded, the switching does not require taking the entire process control block of the currently running process out and load with the other one. It just needs switching the hardware units from which the instructions are to be read.


Quoting Wikipedia:

Hyper-threading works by duplicating certain sections of the processor—those that store the architectural state—but not duplicating the main execution resources. This allows a hyper-threading processor to appear as the usual "physical" processor and an extra "logical" processor to the host operating system.

like image 171
displayName Avatar answered Dec 11 '25 13:12

displayName



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!