Page 1 of 1

Multitasking how to?

Posted: Thu Apr 27, 2006 2:50 pm
by rikrispy
Hi. I try to implement mutithread in my kernel. I searched everywhere, but unfortunately, what I've found wasn't enough for me to be able to implement a multithread environment in my kernel.
In my research I discovered that hardware task switching is bad, right?
Software task switching is the way to go, and is the only way to do it in 64 bits mode?
So I want to do soft switching. How to do it? I'm not after doing processes, just threads, so I can have, for example, 2 functions executing in parallel in my kernel.
Another thing. When a task is executing, the timer interrupt occur, and the scheduler is called in the interrupt, stopping the task, and starting another task, right?
I asked a lot of questions, but please, if you could answer only one question, please give me a clue on how to have threads in my kernel.

ps. english is not my mother tongue, so forgive my syntax ;)

edit: there's another thread on software switching, and I'm invsestigating it, but I'm tired :(
reedit: I don't understand it :(

Re:Multitasking how to?

Posted: Thu Apr 27, 2006 3:55 pm
by rikrispy
I have my interrupt:

_irq000_wrapper:            
   push   %ds         
   push   %es         
   pushl   %eax      
   pushl   %ecx      
   pushl   %edx      
   pushl   %ebx      
   pushl   %ebp      
   pushl   %esi      
   pushl   %edi      
   pushl   %esp
   call   _irq000      
   popl   %esp      
   popl   %edi      
   popl   %esi      
   popl   %ebp      
   popl   %ebx      
   popl   %edx      
   popl   %ecx
   popl   %eax
   pop      %es
   pop      %ds
   sti
   iret

irq000 calls schedule. I think I understand. My kernel begins at the function "begin", which call the function func1. So I need to push the registers ds es eax etc, of "begin" before calling func1. SO I don't really need to store the registers in a stack? Only cr3 esp needs to be? I don't know what to do with cr3.

Re:Multitasking how to?

Posted: Thu Apr 27, 2006 7:03 pm
by rikrispy
The thing is, I didn't have the right intel manual. I've just gone to their website and downloaded 6 pdfs, so things should be clearer now. :-[

Re:Multitasking how to?

Posted: Fri Apr 28, 2006 2:44 am
by viral
Hello...
This a an old post discussing some of these issues. Have a look.
http://www.mega-tokyo.com/forum/index.php?board=1;action=display;threadid=7789;start=msg65251#msg65251

Re:Multitasking how to?

Posted: Fri Apr 28, 2006 6:15 am
by Pype.Clicker
the "scheduling section" of the "E.X.T.E.R.M.I.N.A.T.O.R." (damn why did he put that many dots in his stuff!) may also be instructing, and will have a more practical aspect than theory books.

(yet i haven't reviewed the text myself, but it looked interesting).

Re:Multitasking how to?

Posted: Fri Apr 28, 2006 4:11 pm
by rikrispy
Thank you both of you for your sources. I already downloaded the E.X.T.E.R.M.I.N.A.T.O.R. sources but only superficially took a look at it at first. But now I got deeper into it, and I think I understand.

Re:Multitasking how to?

Posted: Sun Apr 30, 2006 8:47 am
by Pype.Clicker
i was referring to the report (.pdf) rather than the sources, but well, i guess looking at the sources will be fine aswel.