A simple OS

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Whitebird
Posts: 23
Joined: Wed Feb 02, 2011 12:30 pm
Location: Belo Horizonte, Minas Gerais, Brazil
Contact:

A simple OS

Post 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.
Pedro H. Penna.

Undergraduate student of Computer Engineering.

Current OS Project: http://nanvix.blogspot.com/
User avatar
AlfaOmega08
Member
Member
Posts: 226
Joined: Wed Nov 07, 2007 12:15 pm
Location: Italy

Re: A simple OS

Post 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
Please, correct my English...
Motherboard: ASUS Rampage II Extreme
CPU: Core i7 950 @ 3.06 GHz OC at 3.6 GHz
RAM: 4 GB 1600 MHz DDR3
Video: nVidia GeForce 210 GTS... it sucks...
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: A simple OS

Post 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.
Whitebird
Posts: 23
Joined: Wed Feb 02, 2011 12:30 pm
Location: Belo Horizonte, Minas Gerais, Brazil
Contact:

Re: A simple OS

Post 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
Pedro H. Penna.

Undergraduate student of Computer Engineering.

Current OS Project: http://nanvix.blogspot.com/
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: A simple OS

Post 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.
Post Reply