Hardware Multitasking

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

Hardware Multitasking

Post by AJ »

Hello!

I have now cracked software multitasking at last! Some of the problems I had before were that my memory management routines could have been more robust...

I would now like to try out HW multitasking so that I can compare it in my own OS environment. I have read the intel docs and just have one question - do I really need ring 1-3 stack segments and pointers even if my code is running in ring 0, or can I just set up null segment pointers?

If I have to set up the other 3 stack pointers, how are they used by the processor? Why would I need to provide them :?:

Thanks in advance,
Adam
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Hardware Multitasking

Post by Brendan »

Hi,
AJ wrote:If I have to set up the other 3 stack pointers, how are they used by the processor? Why would I need to provide them :?:
When the CPU changes from a lower privilege level to a higher privilege level (e.g. from CPL=3 to CPL = 2, from CPL=1 to CPL=0, etc), it does a stack switch by loading a new SS and ESP from the TSS.

If your OS never changes from a lower privilege level to a higher privilege level, then the CPU will never read the SS0:ESP0, SS1:ESP1 or SS2:ESP2 fields from the TSS, and you can set them to anything you like (or not set them at all). :)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
m
Member
Member
Posts: 67
Joined: Sat Nov 25, 2006 6:33 am
Location: PRC

Re: Hardware Multitasking

Post by m »

Hi,
AJ wrote:Hello!

I have now cracked software multitasking at last! Some of the problems I had before were that my memory management routines could have been more robust...

I would now like to try out HW multitasking so that I can compare it in my own OS environment. I have read the intel docs and just have one question - do I really need ring 1-3 stack segments and pointers even if my code is running in ring 0, or can I just set up null segment pointers?

If I have to set up the other 3 stack pointers, how are they used by the processor? Why would I need to provide them :?:

Thanks in advance,
Adam
Do you mean that you want to CONSTRUCT the multitasking mechanism in your way?
Of course you can do that to save you the trouble implementing the version Intel provides if you think it complex or unnecessary(maybe you don't want to make use of most functions in Intel's version) as well as reading a long long specification(if you just do that for this reason,you can read some relavant in-a-nut-shell documents). :wink:
But anyway,hardware multitasking is more robust,reliable and after all,it has stood the test of time and application.So if you want to make your own,it may be helpful to refer to hardware version to take advantage of it.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Thanks for this.

@m:
You're right in that I implemented my own (stack-swapping) based version first because I didn't want to trawl through the docs. All I'm really doing now is implementing both versions, setting up some performance monitoring stuff and comparing them directly in my own OS environment.

@Brendan:
Thanks for this. As I am still only in a state where I want to run ring 0 code, that means I needn't bother setting up separate data segments for ring 1, 2 and 3 stacks that I didn't really want anyway! :)

Cheers all,
Adam
Post Reply