Page 1 of 1
Multitasking Theory- Part 2
Posted: Tue Jul 30, 2002 9:24 am
by kernel
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
Posted: Tue Jul 30, 2002 11:56 am
by Schol-R-LEA
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?
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:
And, when you jmp to a new task, are you jumping to a memory location to resume the task or what?
thanx ;D
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.
Re:Multitasking Theory- Part 2
Posted: Tue Jul 30, 2002 12:53 pm
by kernel
cool. thanks ;D
Re:Multitasking Theory- Part 2
Posted: Tue Jul 30, 2002 7:32 pm
by Peter_Vigren
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
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.
Re:Multitasking Theory- Part 2
Posted: Fri Aug 02, 2002 11:38 am
by Piotr Sejfried
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
Re:Multitasking Theory- Part 2
Posted: Fri Aug 02, 2002 11:56 am
by srg
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.
But what if you use a flat memory model with single 4GB code and data segments??
Steven Graham
Re:Multitasking Theory- Part 2
Posted: Fri Aug 02, 2002 7:02 pm
by Peter_Vigren
srg wrote:
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.
But what if you use a flat memory model with single 4GB code and data segments??
Steven Graham
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...