Multitasking help

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
MagicalTux
Posts: 22
Joined: Mon Dec 04, 2006 5:34 pm

Multitasking help

Post 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! :)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Multitasking help

Post 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
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply