Switching rings requires a TSS, which implies hardware-based multitasking, yet software multitasking seems to be extremely popular.
Is there some way to do ring-switching in software that I'm not aware of, or is it just that most people stick to ring 0?
Multiple rings with software multitasking
No in SM you only load the ESP0, SS0 field that's all, the registers are saved on the stack. In HM every task has a TSS and the registers are saved in the TSS.yakujabi wrote:but if the processor operates on the same TSS, reading from it and writing into it, isn't that the same as a switch between TSS's?
its probably not but there are other things that make software multitasking faster. More detailed can be found in this thread and many threads like it.yakujabi wrote:so how exactly is saving the registers on the stack faster than letting the processor do the saving?
Hi,yakujabi wrote:so how exactly is saving the registers on the stack faster than letting the processor do the saving?
First of all, it is not faster. However, it is of comparable and similar speed, because saving registers requires quite a few memory bus cycles. Also, with software multitasking the programmer has the option to save only a subset of the available registers, or a superset of those saved by HW task switching (notably the floating point registers, which are not saved by a TSS switch).
The big advantages that people see to software task switching are (a) less bit fiddling in the TSS, (b) infinite tasks - you can only fit a certain number of TSSes into your GDT, and (c) it's FAR more portable. HW task switching will only work on the x86. Software will work in principle without much code modification on other platforms.
Hope this helps,
James