Hi.
I want to implement multitasking in my OS, but I don't understand what I need to do before that.
Now I can work work with the keyboard and I have a primitive physical memory manager (divides the memory into pages and allocate the desired number of pages), is this enough to implement kernel multitasking? Or should I do something else?
I think so, but it's better to ask.
What should be implemented before multitasking?
- AndrewAPrice
- Member
- Posts: 2300
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: What should be implemented before multitasking?
Very close, you just need to implement interrupt handling. Return from the interrupt with a different set of registers (including the instruction pointer and stack pointer) to what you entered with.
Then, this interrupt could be fired from a timer or manually fired by a thread willing to give up control.
Then, this interrupt could be fired from a timer or manually fired by a thread willing to give up control.
My OS is Perception.
Re: What should be implemented before multitasking?
I'd say that allocating memory as pages, rather than smaller amounts, is going to be a little wasteful. I'd recommend writing a memory allocator to hand out smaller chunks of (virtual) memory.
Re: What should be implemented before multitasking?
I already have interrupts, I think I need to implement software interrupts somehow. I also need a timer with millisecond accuracy to switch between tasks. But I don't know what kind of watch will help me.AndrewAPrice wrote:Very close, you just need to implement interrupt handling. Return from the interrupt with a different set of registers (including the instruction pointer and stack pointer) to what you entered with.
Then, this interrupt could be fired from a timer or manually fired by a thread willing to give up control.
- AndrewAPrice
- Member
- Posts: 2300
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: What should be implemented before multitasking?
I found the PIT very easy to use. It'll fire an interrupt on IRQ0.
My OS is Perception.