OSDev.org
https://forum.osdev.org/

What should be implemented before multitasking?
https://forum.osdev.org/viewtopic.php?f=15&t=36760
Page 1 of 1

Author:  mrjbom [ Thu May 14, 2020 1:31 pm ]
Post subject:  What should be implemented before multitasking?

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.

Author:  AndrewAPrice [ Thu May 14, 2020 5:57 pm ]
Post subject:  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.

Author:  iansjack [ Fri May 15, 2020 12:52 am ]
Post subject:  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.

Author:  mrjbom [ Fri May 15, 2020 8:26 am ]
Post subject:  Re: What should be implemented before multitasking?

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.


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.

Author:  AndrewAPrice [ Fri May 15, 2020 1:31 pm ]
Post subject:  Re: What should be implemented before multitasking?

I found the PIT very easy to use. It'll fire an interrupt on IRQ0.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/