3 ms·
> Those are only saved/restored when switching between processes not between threads. Context switching when dealing with threads is typically done in software,
by bhouston 9y ago
> Those are only saved/restored when switching between processes not between threads. Context switching when dealing with threads is typically done in software, not in hardware, precisely so that registers that are not used (like the segment registers) don't get needlessly saved & restored.
You are incorrect. Context switching is done for threads in HW. I think you are thinking of cooperative multi-threading (like pre-Windows 95, or nginx or node.js or V8) instead of true context-switching threading.
- dom0 9y ago> Context switching is done for threads in HW. Uhm, x86-64 can't switch between tasks/contexts in hardware.
- kllrnohj 9y agoAll you need for preemptive multithreading is IRQ#0 to generate an interrupt. That's the entirety of it. Preemptive multiprocessing then needs paging and such to make isolated memory a thing as well, but still doesn't need HW context switching.