OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 2:46 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Need help on how to task switch with TSS
PostPosted: Mon Oct 12, 2020 4:15 am 
Offline
Member
Member

Joined: Tue Jul 14, 2020 4:01 am
Posts: 70
So I'm trying to implement multitasking in my os with TSS, but I can't understand how to use it. There is almost no tutorial on how to switch tasks with it. Also, I understand it's a piece of junk, and it's very slow.


Top
 Profile  
 
 Post subject: Re: Need help on how to task switch with TSS
PostPosted: Mon Oct 12, 2020 4:27 am 
Offline
Member
Member
User avatar

Joined: Tue Sep 15, 2020 8:07 am
Posts: 264
Location: London, UK
clementttttttttt wrote:
So I'm trying to implement multitasking in my os with TSS, but I can't understand how to use it. There is almost no tutorial on how to switch tasks with it. Also, I understand it's a piece of junk, and it's very slow.


Hi Clementt..t, did you read my thread about struggling with the TSS?

viewtopic.php?f=1&t=37265

I describe a very simple software task switch mechanism in this thread.

_________________
CuriOS: A single address space GUI based operating system built upon a fairly pure Microkernel/Nanokernel. Download latest bootable x86 Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip
Discord:https://discord.gg/zn2vV2Su


Last edited by bloodline on Mon Oct 12, 2020 10:42 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Need help on how to task switch with TSS
PostPosted: Mon Oct 12, 2020 6:32 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
Skip TSS based multitasking. The TSS is a pain. On 32 bit, you can look at Brokenthorn for minimal TSS usage examples. 64 bit doesn't even allow you to use it for multitasking You should use software multitasking instead.

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
 Post subject: Re: Need help on how to task switch with TSS
PostPosted: Mon Oct 12, 2020 7:11 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3192
TSS task switching is still useful for some exception handlers (double fault), and as the main method if you don't plan to use multiple cores, but otherwise it's not so good.

Switching tasks with TSS is pretty simple. You just do a far jmp with the TSS as the destination selector. The problem is the TSS busy bit that needs to be modified in some contexts.

As for speed, I don't know. The advantage of the TSS method is that it will null invalid selectors when they are loaded from a TSS, but when software task switching is used, loading them will result in exceptions in the scheduler, and handling this properly will increase complexity in exception handlers.


Top
 Profile  
 
 Post subject: Re: Need help on how to task switch with TSS
PostPosted: Mon Oct 12, 2020 7:16 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
With software multitasking, one could only load registers that had been changed. This would make it faster. Of course one would need to detect this, which could take longer then loading all the registers. I don't use the TSS mainly for portability. x86_64 doesn't provide a full TSS that can do task switches. So it is best to do a software approach.

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 48 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group