Page 1 of 1

Software Task Switching Confusion!

Posted: Thu Mar 05, 2009 1:08 am
by Raven
Hi

I am always advised to use one TSS atleast even if i will use Software technique for task switching.

I am not able to understand the reason?

I checked many tutorials they mention it but donot tell why, please help!



I think it is to allow implicit TSS for interrupts and faults, please comment!

In some code i found that TSS entry like

dw 103

dw 0 ; set to tss

db 0

db 0xE9 ; present, ring 3,etc

db 0

db 0

If my above statement is correct why ring 3?

Re: Software Task Switching Confusion!

Posted: Thu Mar 05, 2009 2:21 am
by Hyperdrive
Raven wrote: I am always advised to use one TSS atleast even if i will use Software technique for task switching.
I am not able to understand the reason?
I checked many tutorials they mention it but donot tell why, please help!
You need the TSS for crossing ring privilege levels, i.e. ring 3 -> ring 0. If you are only working in ring 0 (which is in many cases not to recommend) and you are using software task switching, then you shouldn't need any TSS.

--TS

Re: Software Task Switching Confusion!

Posted: Thu Mar 05, 2009 3:01 am
by AJ
Hi,
Raven wrote:I checked many tutorials they mention it but donot tell why, please help!
http://www.jamesmolloy.co.uk/tutorial_html/10.-User%20Mode.html wrote:With that said, the way the x86 architecture is designed we have no choice but to use at least one TSS. This is because when a program in user mode (ring 3) executes a system call (software interrupt) the processor automatically looks in the current TSS and sets the stack segment (SS) and stack pointer (ESP) to what it finds in the SS0 and ESP0 fields ('0' because it's switching to ring 0) - in essence this switches from the user's stack to your kernel stack.
A link from our very own TSS wiki page wrote:http://forum.osdev.org/viewtopic.php?t=13678
It's also been asked quite a lot on the forums and is, of course in the Intel Manuals.

Cheers,
Adam