Software Task Switching Confusion!

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Raven
Member
Member
Posts: 41
Joined: Sun Feb 01, 2009 12:20 am

Software Task Switching Confusion!

Post 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?
Hyperdrive
Member
Member
Posts: 93
Joined: Mon Nov 24, 2008 9:13 am

Re: Software Task Switching Confusion!

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Software Task Switching Confusion!

Post 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
Post Reply