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

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
DrunkenSlithLord
Posts: 5
Joined: Fri Aug 30, 2013 7:37 pm
Location: Stony Brook, NY

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

Post 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?
In search of the Lost Bahssikava ...
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

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

Post 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.
User avatar
arseniuss
Member
Member
Posts: 32
Joined: Tue Aug 10, 2010 12:13 am
Location: Latvia
Contact:

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

Post 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.
Hobby stuff (suckless libs, compilators, game engines, kernels): github. Work @ zabbix: arseniuss@zabbix
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

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

Post 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.
If you have seen bad English in my words, tell me what's wrong, please.
rdos
Member
Member
Posts: 3270
Joined: Wed Oct 01, 2008 1:55 pm

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

Post 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.
DrunkenSlithLord
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?)

Post by DrunkenSlithLord »

Thank you for the replies.
In search of the Lost Bahssikava ...
Post Reply