Page 1 of 2
Multitasking
Posted: Tue Mar 23, 2010 6:32 pm
by oib111
So I just finished implementing the heap, and I'm trying to implement software multitasking, but I'm really confused. Does anybody have some good articles on it?
Re: Multitasking
Posted: Tue Mar 23, 2010 6:44 pm
by VolTeK
yes, yes we do.
Re: Multitasking
Posted: Tue Mar 23, 2010 7:01 pm
by oib111
GhostXoPCorp wrote:yes, yes we do.
A link would be helpful

Re: Multitasking
Posted: Tue Mar 23, 2010 7:19 pm
by VolTeK
sure would

lol im just being a jerk
try wiki.osdev.org look through there, or google, i promise u, ulll find a lot of info, trust me
Re: Multitasking
Posted: Tue Mar 23, 2010 7:25 pm
by oib111
I already checked the wiki. My problem is, I understand multitasking in theory, I just can't figure out how to implement it.
Re: Multitasking
Posted: Tue Mar 23, 2010 7:47 pm
by VolTeK
welll everything ive ever messed with included single tasking. but look up things like task switching and how to get into multitasking for os development. or look up "how multitasking works os" or wait for osmeone more experienced, lol and thats not me
Re: Multitasking
Posted: Tue Mar 23, 2010 7:50 pm
by oib111
GhostXoPCorp wrote:welll everything ive ever messed with included single tasking. but look up things like task switching and how to get into multitasking for os development. or look up "how multitasking works os" or wait for osmeone more experienced, lol and thats not me
Oh, ok. Well I'm looking things up right now, but once again, any articles would still be great.
Re: Multitasking
Posted: Tue Mar 23, 2010 8:43 pm
by Love4Boobies
In preemptive multitasking, there's usually a timer that goes off (as an interrupt) and its handler performs the context switch, which will save the old state and load the new one.. The most common way to implement this on x86(-64) systems, is to change the return address on the stack to point to the new thread when IRET is executed. What thread you pick next is defined by your scheduling policy.
There are several common timers in x86(-64) systems (PIT/HPET, RTC, RDTSC, and LAPIC), and the one that would make most sense to use is the LAPIC (when present) because you get one per CPU core - you just need to make sure you calibrate it with another timer because there's no other way to reliably determine its operating frequency.
That said, you should aim for software multitasking instead of hardware multitasking - more about this on the wiki and other forum threads.
Re: Multitasking
Posted: Tue Mar 23, 2010 9:18 pm
by oib111
That's what I was thinking, but since I don't plan on putting in SMP support for a while, I was just thinking of using the PIT instead of the LAPIC.
Re: Multitasking
Posted: Tue Mar 23, 2010 9:25 pm
by Love4Boobies
As far as the theory of it is concernet, I'm surprised you didn't consider looking through the wiki:
You will find tutorials provided by JamesM
here. In particular, you care about
IRQs and the PIT and
Multitasking.
Re: Multitasking
Posted: Tue Mar 23, 2010 9:28 pm
by oib111
I actually read his tutorial on Multitasking. I don't know if I'm missing something, but shouldn't he really be saving more than just ebp, esp, and eip for each task?
Re: Multitasking
Posted: Tue Mar 23, 2010 9:42 pm
by Love4Boobies
That's done automatically by the IRQ handler (isr.c). I pointed you to tutorial 5 too for several reasons.
Also, notice that I've added some more links to my previous post.
Re: Multitasking
Posted: Tue Mar 23, 2010 9:51 pm
by oib111
Love4Boobies wrote:That's done automatically by the IRQ handler (isr.c). I pointed you to tutorial 5 too for several reasons.
Also, notice that I've added some more links to my previous post.
Ah didn't notice that. I didn't look at JamesM article on the PIT when I was adding that functionality into my kernel. Thanks

Re: Multitasking
Posted: Sat Mar 27, 2010 2:43 pm
by oib111
Ah, a bit of a problem. I can't load in the new value for ebp without getting an invalid opcode exception.
Re: Multitasking
Posted: Sat Mar 27, 2010 2:48 pm
by piranha
oib111 wrote:Ah, a bit of a problem. I can't load in the new value for ebp without getting an invalid opcode exception.
Well, we're gonna need more information than that...
-JL