Page 1 of 1

Multitasking help

Posted: Thu Dec 21, 2006 10:36 am
by MagicalTux
I'll explain the current situation :

I have a working base OS, 3 gfx drivers, various stuff, and I'm now working on multitasking.

I found a bunch of example codes, various stuff, and managed to make some non-preemptive multitasking (each task has to explicitly tell the world when I can switch).

I've read interesting stuff about task-gade, hardware switching, etc... but it's still not quite clear.

Anyone has some documentation or example code about task switching and multitasking ?

Basically, from what I understood :
- State of each task is saved in a list
- I install an timer exception with my task-switcher
- When the exception happens, I save the current context, restore another task's context, and run it

This way, multitasking should work (from what I could read), but reality is far from theory. I tried to do that using "software task switching" but it just didn't work.

So, help is welcome! :)

Re: Multitasking help

Posted: Thu Dec 21, 2006 3:56 pm
by Combuster
MagicalTux wrote:Anyone has some documentation or example code about task switching and multitasking ?
1: Read the Intel Manuals
2: There are some multitasking tutorials. Browse the OS dev sites that are around
3: http://ringzero.free.fr/os/protected%20mode/Pm/PM8.ASM
4: I'd normally give you an url to my own kernel, but it has gotten too long for the syntax highlighter to handle and now it complains about execution time exceeded... :roll:

Anyway a common way to do this is to push all registers onto the stack, change stack (and possibly switch address space), then pop all registers and you're in the new task