Multitasking
Multitasking
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
yes, yes we do.
Re: Multitasking
A link would be helpfulGhostXoPCorp wrote:yes, yes we do.
Re: Multitasking
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
try wiki.osdev.org look through there, or google, i promise u, ulll find a lot of info, trust me
Re: Multitasking
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
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
Oh, ok. Well I'm looking things up right now, but once again, any articles would still be great.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
- Love4Boobies
- Member

- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Multitasking
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.
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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Multitasking
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.
- Love4Boobies
- Member

- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Multitasking
As far as the theory of it is concernet, I'm surprised you didn't consider looking through the wiki:
- Multitasking
- PIT (for a more detailed description, see Inte'ls description).
- Context switching
Last edited by Love4Boobies on Tue Mar 23, 2010 9:30 pm, edited 3 times in total.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Multitasking
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?
- Love4Boobies
- Member

- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Multitasking
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.
Also, notice that I've added some more links to my previous post.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Multitasking
Ah didn't notice that. I didn't look at JamesM article on the PIT when I was adding that functionality into my kernel. ThanksLove4Boobies 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.
Re: Multitasking
Ah, a bit of a problem. I can't load in the new value for ebp without getting an invalid opcode exception.
- piranha
- Member

- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: Multitasking
Well, we're gonna need more information than that...oib111 wrote:Ah, a bit of a problem. I can't load in the new value for ebp without getting an invalid opcode exception.
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io

