Multitasking how to?

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
rikrispy

Multitasking how to?

Post 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 :(
rikrispy

Re:Multitasking how to?

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

Re:Multitasking how to?

Post 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. :-[
viral

Re:Multitasking how to?

Post 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
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 how to?

Post 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).
rikrispy

Re:Multitasking how to?

Post 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.
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 how to?

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