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
Hardware Multitasking
Re: Hardware Multitasking
Hi,
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
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.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
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.
Re: Hardware Multitasking
Hi,
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.
Do you mean that you want to CONSTRUCT the multitasking mechanism in your way?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
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.
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
@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