Assuming my meagre understanding of x86 architecture and os kernels is correct, Task Gates seem to be the x86 way of switching tasks. But I don't remember coming across any mention of TSS and Task gates in any OS kernel literature. Ditto with using Call Gates for system calls. Am I misunderstanding something?
If I'm correct in my observations - why aren't they used?
Why are task gates and TSS not used? (Are they?)
-
- Posts: 5
- Joined: Fri Aug 30, 2013 7:37 pm
- Location: Stony Brook, NY
Why are task gates and TSS not used? (Are they?)
In search of the Lost Bahssikava ...
Re: Why are task gates and TSS not used? (Are they?)
TSS is mandatory for all x86/x86_64 OS that uses ring3, it is used for stack switches.
However, the original usage of TSS, ie. hardware task switching, is almost obsoleted and only used by very few OS.
The main reason is the overhead involved.
However, the original usage of TSS, ie. hardware task switching, is almost obsoleted and only used by very few OS.
The main reason is the overhead involved.
Re: Why are task gates and TSS not used? (Are they?)
Also TSS may be used if kernel thread crashed and new stack (for exceptions/interrupts) is needed. How I have read, in Linux there is TSS for double fault if I am right.
Hobby stuff (suckless libs, compilators, game engines, kernels): github. Work @ zabbix: arseniuss@zabbix
Re: Why are task gates and TSS not used? (Are they?)
Yes, this technique is used in Windows too.
I use one additional TSS per core for handling #DF. And one per system for NMI handling.
I use one additional TSS per core for handling #DF. And one per system for NMI handling.
If you have seen bad English in my words, tell me what's wrong, please.
Re: Why are task gates and TSS not used? (Are they?)
The original design of hardware task-switching using the TSS wasn't well thought out (especially not in relation to multiple cores). The efficiency argument seems to be less important than the problems with selecting a new thread in the scheduler, a process that typically require saving at least some register state, and thus doing double save-restore on registers. This mechanism should have been designed in two halves instead, one half saving registers and the other half restoring them. Another problem is the "busy" TSS bit, which is a real bad design. TSS hardware task switching works very well for double fault and NMI, but unfortunately it is inefficient for thread switches.
-
- Posts: 5
- Joined: Fri Aug 30, 2013 7:37 pm
- Location: Stony Brook, NY
Re: Why are task gates and TSS not used? (Are they?)
Thank you for the replies.
In search of the Lost Bahssikava ...