OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Nov 24, 2020 8:25 pm

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

Joined: Tue Jul 14, 2020 4:01 am
Posts: 20
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: 155
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.

_________________
Building a single address space Microkernel, as used in embedded applications, for the desktop... Download latest build bootable Disk Image: https://github.com/h5n1xp/CuriOS/blob/main/disk.img.zip


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
User avatar

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 431
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.

_________________
Working on NexBoot, a simple and lightweight GRUB replacement. and NexKe, a stable and fast microkernel. Part of the Nexware Project.


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: 2318
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
User avatar

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 431
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.

_________________
Working on NexBoot, a simple and lightweight GRUB replacement. and NexKe, a stable and fast microkernel. Part of the Nexware Project.


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], foliagecanine, Google [Bot] and 13 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