Page 1 of 1
Hardware Multitasking
Posted: Thu Dec 14, 2006 3:58 am
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
Re: Hardware Multitasking
Posted: Thu Dec 14, 2006 5:00 am
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
Re: Hardware Multitasking
Posted: Thu Dec 14, 2006 5:15 am
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).
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.
Posted: Thu Dec 14, 2006 6:36 am
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