Page 1 of 1
A simple OS
Posted: Sat Feb 26, 2011 1:58 pm
by Whitebird
Hello everyone!
I'm developping a simple OS that only it does is execute a single application. So, I'll have only few tasks running: kernel, drivers, and this apllication.
My question is:
Have I need to write a memory manager, implement virtual memory, paging...?
Can I just fixed some region of memory, load application there, and add it to task queue?
Thank you.
Re: A simple OS
Posted: Sat Feb 26, 2011 3:02 pm
by AlfaOmega08
Whitebird wrote:Have I need to write a memory manager, implement virtual memory, paging...?
A memory manager is required if you plan to use malloc/free or new/delete. If not you can skip this.
Paging will ensure that your application will not destroy the kernel. However this is optional too, just pay attention when writing the app.
Whitebird wrote:Can I just fixed some region of memory, load application there, and add it to task queue?
Yes
Re: A simple OS
Posted: Sat Feb 26, 2011 3:39 pm
by Tosi
If you pick a fixed area of memory, how do you know it will be guaranteed to be available for use? It might be memory-mapped hardware, or beyond the limits of available RAM. You could get a memory map from the BIOS or a multiboot bootloader, and then parse that. That's what I do. Or, since you only have one task at a time, put it after the "end" of your kernel which hopefully is available RAM.
Some form of memory protection, whether it be through paging or segmentation, is a must. If you're not going to have protection, then your OS is not much more advanced than DOS, other than maybe having more drivers.
I would still recommend writing a memory allocator, whether you have memory protection or not. Even if you only have one application running, if it wants memory, you're going to need something like sbrk or malloc.
Re: A simple OS
Posted: Sat Feb 26, 2011 8:12 pm
by Whitebird
Thanks for replying me!
I've already implemented kmalloc and free functions, using a heap.
The "fixed regions" are know area of memory, that won't be any BDA, EBDA or something like this. And the application that the OS will run I will develop myself, so I will know that never I will enter in other memory region (eg kernel).
I was just confused if I really have to write something like pagigin for more than just memory protection (I'm sure that I will not need it).
Other confusing thing: if my kernel, my drivers and my application run in ring 0, do I need to set TSS? Is there some other way to do context switch?
Thank you again
Re: A simple OS
Posted: Sun Feb 27, 2011 8:47 am
by Tosi
I think you need at least one TSS for switching back to ring 0 from ring 3 on interrupts. However, you can use software task switching for everything else.