Ok, I have 2 simple questions about multitasking.
First, before your schedular switches tasks, does it save the current register values somewhere and load the new tasks register values?
And, when you jmp to a new task, are you jumping to a memory location to resume the task or what?
thanx ;D
Multitasking Theory- Part 2
Re:Multitasking Theory- Part 2
Yes. In the simple example I gave before, it pushed them onto the task's local stack before switching to the scheduler's stack. When running in protected mode, I believe that there are hardware-supported methods for saving and restoring task contexts, though I don't know the details of that yet myself. Regardless of how it is done, yes, the registers have to be saved when switching out of a task, and restored when switching back into one.kernel wrote: Ok, I have 2 simple questions about multitasking.
First, before your schedular switches tasks, does it save the current register values somewhere and load the new tasks register values?
Basically, yes, but usually it would take the form of either a function return or (more likely still for a x86 real-mode kernel) an interrupt return, rather than a simple jump. Once again, that is just the simplest case; in p-mode there are other mechanisms that you'd probably use instead (e.g., task gates), but they amount to much the same effect.kernel wrote: And, when you jmp to a new task, are you jumping to a memory location to resume the task or what?
thanx ;D
Re:Multitasking Theory- Part 2
In protected mode, you can faciliate the built-in task switching support of the processor... which automaticly saves/restores all registers and other relevant information upon task switch (often triggered by the timer interrupt for scheduling purpose) if you have set up the necessary selectors and such correctly.kernel wrote: Ok, I have 2 simple questions about multitasking.
First, before your schedular switches tasks, does it save the current register values somewhere and load the new tasks register values?
And, when you jmp to a new task, are you jumping to a memory location to resume the task or what?
thanx ;D
Re:Multitasking Theory- Part 2
Hello,
I see that you are talking about Mu;titasking in protected mode. Is there anyone who knows
something more about it? Somebody who can
help in writeing 32 bit pmode multitasking kernel?
Best Regards
Peter
I see that you are talking about Mu;titasking in protected mode. Is there anyone who knows
something more about it? Somebody who can
help in writeing 32 bit pmode multitasking kernel?
Best Regards
Peter
Re:Multitasking Theory- Part 2
But what if you use a flat memory model with single 4GB code and data segments??In protected mode, you can faciliate the built-in task switching support of the processor... which automaticly saves/restores all registers and other relevant information upon task switch (often triggered by the timer interrupt for scheduling purpose) if you have set up the necessary selectors and such correctly.
Steven Graham
Re:Multitasking Theory- Part 2
I'm not really sure what you mean... If you mean that you want to run a number of tasks while sharing memory, then that is easily done...srg wrote:But what if you use a flat memory model with single 4GB code and data segments??In protected mode, you can faciliate the built-in task switching support of the processor... which automaticly saves/restores all registers and other relevant information upon task switch (often triggered by the timer interrupt for scheduling purpose) if you have set up the necessary selectors and such correctly.
Steven Graham