Is there any easy step-by-step tutorial of TSS? (v2)

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.
InsightSoft
Member
Member
Posts: 76
Joined: Mon Aug 18, 2008 6:17 am

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by InsightSoft »

Combuster wrote:using a far return, far jump, far call, or task gate have severe implications on how the task state works.

I do this from memory, but you should *really* look all this up and not do all this shotgun debugging. If something did work out here, you would have learned little from it. And regrettably, you have not been doing your homework AT ALL (and next time you WILL be left without answer)

A far jump will mark the current tss as idle, and the new one as busy (must have been idle)
A far call will mark the new tss as busy (must have been idle), store a pointer in the backlink field, and leaves the original busy as well
An iret (with NT set) will jump to the task in the backlink pointer (must be busy) and marks the current one as idle
A far return may never return to another TSS.


There is a reason why everybody else uses the far more simple software task switching.
Thanks for your help!
software based task switching is already done (up and running)... but I will try for more one (or two) weeks trying to understanding the intel based...
...about be left without answer: Well this is the risk that I will take. Otherwise, I consider lost of time posting messages, asking for help of something that I already understand... I accept this risk because in this sequences of text I learn a lot... (So, thanks every one of you)
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by ru2aqare »

Combuster wrote: A far return may never return to another TSS.
Oops. I remembered using retf to switch tasks, but I guess I was wrong. I only used hardware task switching in very early versions of my kernel (it was more than four-five years ago, going by the timestamps), and I don't even have them sources any more. My bad for suggesting an invalid method.
InsightSoft
Member
Member
Posts: 76
Joined: Mon Aug 18, 2008 6:17 am

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by InsightSoft »

Hi again,

Now I have intel based task switching (I have on idt a task gate pointing to gdt.tss)
for experience I put two task switching each other...

1. endless loop (gdt tss index 4)
2. irq time handler (idt task gate 32 pointing to gdt tss index 3)

Brief description: when irq.0 arrives; choose idt index 32; that is a task gate pointing to gdt index 3; that is tss point to time handler...
it is working perfectly. It start the task (time handler) saving previous task (endless loop) and mark the field Previous Task Link with 20 (to restore after IRETD)


But I still have this problem: to start the task (endless loop) I need to fill the stack with values and them simulate an IRETD...
but I need to do "by the book" jmp selector:0

This is the 4 index on gdt

Code: Select all

Byte * Address Mem * Value
------------------------
0    *   0x115ad1    *   0x67
1    *   0x115ad2    *   0x00
2    *   0x115ad3    *   0x62
3    *   0x115ad4    *   0x57
4    *   0x115ad5    *   0x10
5    *   0x115ad6    *   0x89
6    *   0x115ad7    *   0x00
7    *   0x115ad8    *   0x00

TSS Base: 0x105762
TSS Size: 0x67

Code: Select all

size
b0 b1 b6'	= 67 00 0

base
b2 b3 b4 b7	= 62 57 10 00

b5		= 89	10001001	p=1  -  dpl=00  -  s=0  -  x=1  -  0=0  -  B=0  -  1=1    (When create)
		= 8b	10001011	p=1  -  dpl=00  -  s=0  -  x=1  -  0=0  -  B=1  -  1=1    (after LTR)

b6'		= 0  	0000  	        g=0  -  0=0  -  0=0  -  avl=0	
Everything seems to me that is correct, but when I use

Code: Select all

jump far 20:0
I get this error "jump_protected: gate type 11 unsupported" (I'm getting frustrated)

Im really lost... any clue?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by Combuster »

Your GDT is still borked. You have an invalid system descriptor in there (11 = 0xb) - which is a BUSY task.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
InsightSoft
Member
Member
Posts: 76
Joined: Mon Aug 18, 2008 6:17 am

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by InsightSoft »

Combuster wrote:Your GDT is still borked. You have an invalid system descriptor in there (11 = 0xb) - which is a BUSY task.
Ok... The problem was that my jump come just after LTR that sets that bit...

Thanks Comb...
InsightSoft
Member
Member
Posts: 76
Joined: Mon Aug 18, 2008 6:17 am

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by InsightSoft »

Hi,

I have everything working just good...

My next question is a little bit estrange, but...
I have been googled for a lot experienced guys, how they think, their habits, etc... The majority of them prefer to use the stack based task switch approach. But, my question is: Be using intel based seams to me that is more efficient and more easy... how, exactly is their motivation? Personally I start using stack based (You know, was more intuitive, etc) But after take control (thanks to you guys) the intel based, I don't want anything else...

Thanks again...
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by ru2aqare »

InsightSoft wrote:Hi,

I have everything working just good...

My next question is a little bit estrange, but...
I have been googled for a lot experienced guys, how they think, their habits, etc... The majority of them prefer to use the stack based task switch approach. But, my question is: Be using intel based seams to me that is more efficient and more easy... how, exactly is their motivation? Personally I start using stack based (You know, was more intuitive, etc) But after take control (thanks to you guys) the intel based, I don't want anything else...

Thanks again...
There are two major issues concerning hardware tasking. First is it's not portable to x64. Second is that it's slower than using stack-based tasking (I don't know the exact figures, but there was a thread about measuring the performance loss, if I remember correctly). A minor issue is that you can't have unlimited amount of TSS selectors, while you can have unlimited amount of tasks if you use the stack-based method (limited by only the amount of memory available).
InsightSoft
Member
Member
Posts: 76
Joined: Mon Aug 18, 2008 6:17 am

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by InsightSoft »

ru2aqare wrote:There are two major issues concerning hardware tasking. First is it's not portable to x64. Second is that it's slower than using stack-based tasking (I don't know the exact figures, but there was a thread about measuring the performance loss, if I remember correctly). A minor issue is that you can't have unlimited amount of TSS selectors, while you can have unlimited amount of tasks if you use the stack-based method (limited by only the amount of memory available).
ok I see... thanks
(Is there any study about the performance comparing this two?)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by Combuster »

(Is there any study about the performance comparing this two?)
If there wasn't, why then do we know that TSS switching is worse? :roll:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
InsightSoft
Member
Member
Posts: 76
Joined: Mon Aug 18, 2008 6:17 am

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by InsightSoft »

Combuster wrote:
(Is there any study about the performance comparing this two?)
If there wasn't, why then do we know that TSS switching is worse? :roll:
I do believe, after ru2aqare explanation, that may be the TSS is not good as I thought... but you know, I would like to read a little bit more... And if you have, for example, any reference for further reading, I appreciate...

Thanks,
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by Combuster »

This forum and google, obviously...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
InsightSoft
Member
Member
Posts: 76
Joined: Mon Aug 18, 2008 6:17 am

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by InsightSoft »

Combuster wrote:This forum and google, obviously...
Ok... Should be enough...
InsightSoft
Member
Member
Posts: 76
Joined: Mon Aug 18, 2008 6:17 am

Re: Is there any easy step-by-step tutorial of TSS? (v2)

Post by InsightSoft »

Thanks,
Post Reply