2 ms·
What does it mean for processor to support threads? I thought that threads are OS-level abstraction.
by vbezhenar 5y ago
What does it mean for processor to support threads? I thought that threads are OS-level abstraction.
- anaisbetts 5y agoYou need a programmable timer interrupt to be able to preempt running code, but in general you're right
- amelius 5y agoWell, the processor needs to be able to do the context-switching (switch all registers, i.e. the visible state of the cpu, with those of another thread). You can obviously do this in software (emulate it) but that would be too slow for most practical purposes. Hence the question.
- monocasa 5y agoMost context switching code happens in software. It's only occasionally that cores have hardware task switch support.
- amelius 5y agoInterestingly, Intel has hardware context switching support, but apparently Linux and Windows don't use it. https://en.wikipedia.org/wiki/Context_switch#Hardware_vs._software https://en.wikipedia.org/wiki/Context_switch#Hardware_vs._so...
- monocasa 5y agoYeah, that was it's own system that had a lot of mismatches with how different OSes wanted to conceive of task switching. Where Intel ended up was the xsave/xrestor family of instructions to save and restore processor state according to a bit flag argument of high level functional units. And that's really only because of how complex all of the extensions to x86 have been over the years; a fresh arch is probably just better off manually writing everything with normal loads and stores until right around the iret equivalent. Dumps between the register file and memory show up on perf traces anyway so it's generally a very optimized path in the CPU for general uses anyway.