Multitasking

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
aladdin

Multitasking

Post 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?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Multitasking

Post 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 ...
cgm

Re:Multitasking

Post by cgm »

edit: irrelevant comment from anonymous guest deleted.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Multitasking

Post 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?
Only Human
Ozguxxx

Re:Multitasking

Post 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.
mr. xsism

Re:Multitasking

Post 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?
Ozguxxx

Re:Multitasking

Post 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
Post Reply