Hi,
I'm trying to make a microkernel, but i have some questions about the desing, maybe some silly questions but i can't found more info or clarifiying info. My previous Os project was an attempt to build a monolitic kernel.
One of them, is where you put the mm? mapped in all spaces or not? Something like a user malloc, is called by some syscall that changes for r3 to r0?
Every syscall make ring level change? or uses an IPC ( for all? )?
I've a little mind caos as yuo can see..
Microkernel design
- spix
- Member

- Posts: 128
- Joined: Mon Jun 26, 2006 8:41 am
- Location: Millicent, South Australia
- Contact:
Re:Microkernel design
Perhaps try studying code of existing microkernel projects, there are a number available with source.
L4Ka
http://l4ka.org/projects/pistachio/
GNU Mach
http://www.gnu.org/software/hurd/gnumach.html
The Spoon Microkernel
http://www.djm.co.za/spoon/smk.php
The L4Ka site has lots of info (check the publications link), and links to info on the L4 specification and how they designed theirs - check L4hq.org.
I hope that helps.
Andrew
L4Ka
http://l4ka.org/projects/pistachio/
GNU Mach
http://www.gnu.org/software/hurd/gnumach.html
The Spoon Microkernel
http://www.djm.co.za/spoon/smk.php
The L4Ka site has lots of info (check the publications link), and links to info on the L4 specification and how they designed theirs - check L4hq.org.
I hope that helps.
Andrew
-
mystran
Re:Microkernel design
Well, you will ofcourse need a few different kinds of memory managers. User malloc is typically just normal user code. Kernel might need it's own malloc, althought with microkernel you might be able to survive without one.Alberich wrote: One of them, is where you put the mm? mapped in all spaces or not? Something like a user malloc, is called by some syscall that changes for r3 to r0?
What we are probably talking about here is the virtual memory management? You will need some of that in kernel, and I'd try to keep it mapped in every space just like rest of the kernel. Ofcourse, since we are speaking about microkernels, you might want to have parts of your virtual memory management in user processes, but that's a bit too diverse and complicated issue to answer in a single post, especially as it's still somewhat a research topic.
In typical system every syscall needs a ring level change, and typically IPC works with syscalls. Many microkernels try to minimize the number of proper system calls, and use the generic IPC system calls for most things that a monolithic kernel would have specific calls for.Every syscall make ring level change? or uses an IPC ( for all? )?
So in a messaging microkernel you might have system calls for IPC primitives like [tt]send()[/tt] and [tt]receive()[/tt] and then implement things like opening and reading files by sending messages to the correct server.
-
Alberich
Re:Microkernel design
Thanks for the links spix, 
And thanks for your answears mystream.
And kernel won't need a something like kmalloc?
And thanks for your answears mystream.
Well, so user malloc stays on user space: so when i load a process i tell the linker to link with this malloc no?User malloc is typically just normal user code. Kernel might need it's own malloc, althought with microkernel you might be able to survive without one.
And kernel won't need a something like kmalloc?
Wich parts of mm should be in user space? if i haven't read this i will try to put it all on kernel space. Which is the advantage of map kernel in all addresses space? is something about performance, so kernel won't need to load/change pagedir for example?You will need some of that in kernel, and I'd try to keep it mapped in every space just like rest of the kernel. Ofcourse, since we are speaking about microkernels, you might want to have parts of your virtual memory management in user processes
a ring level change is so slow isn't it? Is there some way to avoid it, in adition with the rl change we have ipc wich pass a message ( so copy memory )..more performance hit in the system?In typical system every syscall needs a ring level change, and typically IPC works with syscalls. Many microkernels try to minimize the number of proper system calls, and use the generic IPC system calls for most things that a monolithic kernel would have specific calls for.
-
mystran
Re:Microkernel design
Well, whether you need kmalloc depends on whether you need to do dynamic allocation in your kernel. There are designs which don't need a kmalloc, but it's a lot easier if you have one.Alberich wrote: Well, so user malloc stays on user space: so when i load a process i tell the linker to link with this malloc no?
And kernel won't need a something like kmalloc?
In any case, you should separate two concepts:
- page management (VMM)
- block management (malloc)
A linker-loader doesn't really need a malloc at all. It just needs pages of memory to put the different segments. The malloc that an user process will use is just a normal library procedure (which might want to make system calls for more memory to manage but that's it).
This isn't actually any different from a monolithic kernel.
Well, the classic idea of a microkernel is to put as much as possible into user space. You want manipulation of the actual hardware page tables in kernel space, I guess, but other than that's it's up to you how much you want to try to get into userspace.Wich parts of mm should be in user space? if i haven't read this i will try to put it all on kernel space. Which is the advantage of map kernel in all addresses space? is something about performance, so kernel won't need to load/change pagedir for example?
Typically paging would be the first to go into userspace, but where you put the line is really up to you.
As for mapping kernel in every address space: yeah, switching page directories is rather expensive especially on IA-32, thanks to TLB flushes.
You can't really avoid the normal system call overhead, but just switching ring level (usually doing software interrupt) isn't terribly costly. Remember that you are doing this every time you get an interrupt anyway.a ring level change is so slow isn't it? Is there some way to avoid it, in adition with the rl change we have ipc wich pass a message ( so copy memory )..more performance hit in the system?
If you are concerned about speed, then the trick is to perform as much useful work per system call as possible, while trying to trash as few caches as possible.