Page 1 of 1
Multitasking
Posted: Mon Mar 22, 2004 5:56 am
by aladdin
as i know, we can switch from one task to another by doing a jmp, iret ... to it's tss segment descriptor, the new task will continue executing till the end of its code the return to the parent task, but what about simulating multi CPUs ?
I know that this is possible by allowing each task to use cpu for a mement then switch to other task ...etc, how this can be done ? since we must call the new task from the other one?
Re:Multitasking
Posted: Mon Mar 22, 2004 8:35 am
by Pype.Clicker
the trick is to switch from one task to another can be placed in the timer interrupt, so that the switch is invisible to the interrupted task ...
Re:Multitasking
Posted: Mon Mar 22, 2004 8:42 am
by cgm
edit: irrelevant comment from anonymous guest deleted.
Re:Multitasking
Posted: Mon Mar 22, 2004 11:31 am
by Neo
Pype.Clicker wrote:
the trick is to switch from one task to another can be placed in the timer interrupt, so that the switch is invisible to the interrupted task ...
So the timer is a sort of main thread (kernel i mean) that calls the other tasks? then how is the scheduling algortihm called (or is it part of the timer code)? or am i missing something?
Re:Multitasking
Posted: Mon Mar 22, 2004 2:36 pm
by Ozguxxx
You can call your scheduler while handling timer interrupts and scheduler decides if current task will be dispatched or not, if it is dispatched then this task will be left into its tss while handling a timer interrupt and cpu will be switched into context of another thread that was previously saved while handling a timer interrupt.
So the timer is a sort of main thread
So, in that case timer is not a thread, so no chicken-egg chaos here

. Interrupts are always occuring and they are handled in kernel context, or in a conforming code segment which is really not a good design I think... ON the other hand also you can make task switches at interrupts so you can have interrupt tasks but I dont think you will need anything like this since it severely decreases performance. (OK, this is arguable, I am not really knowing about performance.) I hope I am clear, good luck.
Re:Multitasking
Posted: Mon Mar 22, 2004 9:24 pm
by mr. xsism
question about interrupts and tasking n such. When an interrupt is called by a ring3 app, does the ring change to ring0 since the interrupt's code is in kernel space?
Re:Multitasking
Posted: Tue Mar 23, 2004 1:38 am
by Ozguxxx
When an interrupt is called by a ring3 app, does the ring change to ring0 since the interrupt's code is in kernel space?
[tt]from Ozgunh82 posted on 22-Mar-04, 02:36pm[/tt]
Interrupts are always occuring and they are handled in kernel context