Page 1 of 1

Why are task gates and TSS not used? (Are they?)

Posted: Fri Aug 30, 2013 7:49 pm
by DrunkenSlithLord
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?

Re: Why are task gates and TSS not used? (Are they?)

Posted: Fri Aug 30, 2013 10:18 pm
by bluemoon
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.

Re: Why are task gates and TSS not used? (Are they?)

Posted: Sat Aug 31, 2013 1:27 am
by arseniuss
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.

Re: Why are task gates and TSS not used? (Are they?)

Posted: Sat Aug 31, 2013 11:03 am
by egos
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.

Re: Why are task gates and TSS not used? (Are they?)

Posted: Sun Sep 01, 2013 3:11 am
by rdos
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.

Re: Why are task gates and TSS not used? (Are they?)

Posted: Mon Sep 16, 2013 7:33 am
by DrunkenSlithLord
Thank you for the replies.