The Holy War: Monolithic vs. MicroKernel
The Holy War: Monolithic vs. MicroKernel
What are the main differences between the two and what are their strong/weak points?
I'm guessing choosing which kernel model your going to fallow is a big decision in the development process of an OS (though I might be wrong). I'm going for speed and stability. I also want a (semi) modular OS. This might be stuck in the middle of them both? Hybrid kernel anyone?
P.S. Sorry - this is probably another recuring topic . Any decent online resources on this topic?
I'm guessing choosing which kernel model your going to fallow is a big decision in the development process of an OS (though I might be wrong). I'm going for speed and stability. I also want a (semi) modular OS. This might be stuck in the middle of them both? Hybrid kernel anyone?
P.S. Sorry - this is probably another recuring topic . Any decent online resources on this topic?
Re:The Holy War: Monolithic vs. MicroKernel
I guess I can give a very short rundown.
A microkernel has the advantages of:
- inherent design modularity,
- OS code running in user land is easier to develop / debug,
- e.g. a driver failure cannot kill the kernel (but might render the driven hardware useless until reboot).
With a monolithic kernel, modularity is a result of your effort, not inherent in the concept.
While having less kernel / supervisor code has the advantage of faciliating robustness and modularity, it also means the microkernel has to pass more messages around - everything stands and falls with the performance of the IPC / signaling subsystem. A monolithic kernel can merely toss pointers around in kernel space, since no address space boundaries have to be crossed. Most early microkernel systems showed inferor performance compared to monolithic ones.
That's the invariants. All the rest is opinion.
A microkernel has the advantages of:
- inherent design modularity,
- OS code running in user land is easier to develop / debug,
- e.g. a driver failure cannot kill the kernel (but might render the driven hardware useless until reboot).
With a monolithic kernel, modularity is a result of your effort, not inherent in the concept.
While having less kernel / supervisor code has the advantage of faciliating robustness and modularity, it also means the microkernel has to pass more messages around - everything stands and falls with the performance of the IPC / signaling subsystem. A monolithic kernel can merely toss pointers around in kernel space, since no address space boundaries have to be crossed. Most early microkernel systems showed inferor performance compared to monolithic ones.
That's the invariants. All the rest is opinion.
Every good solution is obvious once you've found it.
Re:The Holy War: Monolithic vs. MicroKernel
I stick with Micro Kernel design, thou' it is a ***** sometimes. But with certain tricks one can solve each and every problem.
The Big ***** with Micro Kernel Design(tm) is how to get Protocols between the parts of it sorted right so that communication and data passing happens correctly. It can f. ex. happen that you copy data from the floppy driver into any user process adress space just because you didn't wake up the file service (which of course wanted the block ust read) and have it send a message back to say "Hi, I am awake, gimme the data" - to have the correct page directory loaded. There exist other ways to achieve this, but --- they seem too brute a hack to me.
But other than that: once you've got the knack of it, you won't do it the other way, just because it is fun to toss messages back and forth between processes and know: Yes, it is a good feeling to do it this way.
Just recently it happened that I exchanged the fixed process slots by a linked list in the process mnagement part of the micro kernel - the one which is responsible for the process creation and message passing stuff. And puff - except of some very hard to find bugs it sliped into the entire design without problems. I don't know whether this would go that smooth with monolithic kernel design.
Well ... the more, I am reading Tanenbaums OS-Dev Book, so I am somewhat educated for designing the kernel in Micro kernel way. And no, I don't do it the minix way. I do it my way.(f. ex. linked list process management, store and forward message passing for async. communication etc.) What I think, I need to implement is semaphores as extra two system calls (up, down) to faciliate synchronisation between threads.
I 'd stay with Micro Kernel Design. Stay safe.
BI
The Big ***** with Micro Kernel Design(tm) is how to get Protocols between the parts of it sorted right so that communication and data passing happens correctly. It can f. ex. happen that you copy data from the floppy driver into any user process adress space just because you didn't wake up the file service (which of course wanted the block ust read) and have it send a message back to say "Hi, I am awake, gimme the data" - to have the correct page directory loaded. There exist other ways to achieve this, but --- they seem too brute a hack to me.
But other than that: once you've got the knack of it, you won't do it the other way, just because it is fun to toss messages back and forth between processes and know: Yes, it is a good feeling to do it this way.
Just recently it happened that I exchanged the fixed process slots by a linked list in the process mnagement part of the micro kernel - the one which is responsible for the process creation and message passing stuff. And puff - except of some very hard to find bugs it sliped into the entire design without problems. I don't know whether this would go that smooth with monolithic kernel design.
Well ... the more, I am reading Tanenbaums OS-Dev Book, so I am somewhat educated for designing the kernel in Micro kernel way. And no, I don't do it the minix way. I do it my way.(f. ex. linked list process management, store and forward message passing for async. communication etc.) What I think, I need to implement is semaphores as extra two system calls (up, down) to faciliate synchronisation between threads.
I 'd stay with Micro Kernel Design. Stay safe.
BI
Re:The Holy War: Monolithic vs. MicroKernel
Monolithic is more inclusive as far as functionality over micro design. Although there are alternative models that incorporate positive aspects of both model.
Overall, there is no holy war. Thses models actaully already share many good similarities. When performance and modularity are considered(2 important aspects) both kernel models 'weigh' the same. They level out with their tradeoffs.
Microkernels tend to be slower by nature, but more modular. While monolithic kernels are faster due to localization of kernel and driver code. With today's CPU speeds increasing and prices decreasing(see Moore's law), the microkernel model begins to have an edge over monolithic kernels.
**if this is unorganized or rambles on, sorry. It's 12:22AM here **
mr. xsism
Overall, there is no holy war. Thses models actaully already share many good similarities. When performance and modularity are considered(2 important aspects) both kernel models 'weigh' the same. They level out with their tradeoffs.
Microkernels tend to be slower by nature, but more modular. While monolithic kernels are faster due to localization of kernel and driver code. With today's CPU speeds increasing and prices decreasing(see Moore's law), the microkernel model begins to have an edge over monolithic kernels.
**if this is unorganized or rambles on, sorry. It's 12:22AM here **
mr. xsism
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:The Holy War: Monolithic vs. MicroKernel
i do have a modular microkernel (i mean, you can add modules to the microkernel as you would add them to a monolithic one) ... i guess i must be insane or something ...
Re:The Holy War: Monolithic vs. MicroKernel
as long as it rocks like hell (imagine CLicker 32 playing guitar on Devils Walking Stick), nothing speaks against a modular micro kernel ]:-> And if I remember correctly, the last time I gave Clicker a try, it did rock like hell. So I don't care about ... concepts like sanity. They for one don't fit under a cpu's hood.
stay safe.
stay safe.
Re:The Holy War: Monolithic vs. MicroKernel
I have a modular monolithic kernel (drivers run as part of the kernel, but all drivers are in separate files), but a lot of system services (e.g. GUI) run as processes in user mode. So Mobius is confused.
Re:The Holy War: Monolithic vs. MicroKernel
I'm running quite good with a monolothic kernel. Just keep it simple. In my opinion, a micro kernel is much, much too complicated. Monolothic is good and easy. Well, that is a question of design.
Re:The Holy War: Monolithic vs. MicroKernel
A monolithic kernel has little or no structure. "The structure is that there is no structure." (Andrew Tanenbaum in OSDI.) The code is certainly partitioned into separate source files, but they are all linked into a big glob of a binary, with the exception of modules. A monolithic kernel is a collection of procedures, like a massive C program. The whole kernel consists of its functionality partitioned off into these procedures. Everything is in the kernel - drivers, networking, terminal handling, filesystems, etc. All these are implemented in terms of procedures. Even with modules, the kernel normally keeps a table of function pointers which resolve to procedures in the modules.xxchrisxx wrote: What are the main differences between the two and what are their strong/weak points?
A microkernel is a minimal kernel. It contains just enough functionality so that "everything else" can be implemented on top of it. A microkernel typically only includes processes, scheduling, memory management, IPC and perhaps some device drivers. All other functionality, like networking, filesystems, terminal handling and even some drivers are simply servers that run as processes on the microkernel.
The disadvantage to monolithic kernels is that feature creep or "futureitis" can cause massive bloat. Even small changes to the kernel can break the whole thing, because of the intricate interdependencies in the procedures that are all in each others' pants. On the upside, they are arguably simpler to hack together, and they are faster and more efficient than microkernels because drivers and such are all statically linked to the binary. Calling a procedure is faster than using IPC to communicate with a process running on a microkernel.
The disadvantage to microkernels is that they are somewhat slower (see comments above about monolithic efficiency.) They are somewhat more difficult to develop. Where does the minimal functionality end? When having drivers running as processes, what happens to your interrupt latency, do interrupts run too long? You need to write some really slim, lean and mean code in a microkernel to achieve fast robust performance comparable to a monolithic kernel. The advantage of a microkernel is that a change won't break the entire kernel, assuming you are changing the service processes. Also one service process crashing will not necessarily crash the entire system. Also you can plug and chug with different service processes at runtime without recompiling the kernel or service processes. A microkernel is also much easier to maintain than a monolithic kernel. You don't have to get your head around all that source code to make change X. You work in the context of a process running atop the kernel, or you are working in a small, tight microkernel.
There are other advantages and disadvantages, but these are the main ones.
For me, my money is on the microkernel design. All my kernel development will be the microkernel/server design. I don't want my kernel development to crash to a halt at some point in the future where it's just a huge fat pig and seriously broken from feature creep and spaghetti code. This is a serious issue in current Linux kernels - feature creep and "futureitis" I mean. Debugging and making a usable monolithic kernel when it's been in heavy, constant development for a decade is not a trivial task. Further, not a single developer understands the entire system and all possible kernel control paths. It's physically impossible. You're brushing on the limits of what a human being is capable of.
If you're going to write a production consumer OS, make it a microkernel or die an early death from not being able to expand and accommodate all those new features.
Re:The Holy War: Monolithic vs. MicroKernel
kernel.com.au: You've got some vast generalisations there. The only difference between monolithic and micro kernels is in where the system services run. In a monolithic kernel, they're all in one address space. In a microkernel, they're split into separate address spaces.
Structure doesn't come into it. The NT kernel is highly structured -- it even has separate microkernel-style kernel and executive components -- but it's not a microkernel. The Minix kernel is a blob of global variables and functions, yet each system service runs in a different task.
If "microkernel" meant "it has a structure", and vice versa, then you could categorise pretty much any program as a monolithic or micro kernel. This is missing the point.
Kernels are just programs which happen to contain special machine code instructions for accessing processor features. The normal rules of software development apply. Adhering to one scheme (monolithic kernel) does not imply bloat. Writing a microkernel doesn't make you immune from bloat.
Structure doesn't come into it. The NT kernel is highly structured -- it even has separate microkernel-style kernel and executive components -- but it's not a microkernel. The Minix kernel is a blob of global variables and functions, yet each system service runs in a different task.
If "microkernel" meant "it has a structure", and vice versa, then you could categorise pretty much any program as a monolithic or micro kernel. This is missing the point.
Kernels are just programs which happen to contain special machine code instructions for accessing processor features. The normal rules of software development apply. Adhering to one scheme (monolithic kernel) does not imply bloat. Writing a microkernel doesn't make you immune from bloat.
Re:The Holy War: Monolithic vs. MicroKernel
Either can be stable and secure. If you can be sure that the drivers will all be perfect (no bugs) then go for monolithic because it'll be quicker. However if you're using third party drivers then go for a microkernel but it will be slower.
IMHO either can be modular as there isn't much difference between loading stuff into and outof kernel space, and user space.
Pete
IMHO either can be modular as there isn't much difference between loading stuff into and outof kernel space, and user space.
Pete
Re:The Holy War: Monolithic vs. MicroKernel
i looked at having a micro kernel that only implemented IPC in the 'kernel' and all else ran at ring3 in sep processes. but then you need ring0 for task switching, mem management etc.. so....
what I am going for is a modular monolithic kernel. my bootloader is basically a runtime linker, linking whatever drivers it needs at bootup. but everything will be separate files so no recompiling the kernel will be required to change drivers etc.
what I am going for is a modular monolithic kernel. my bootloader is basically a runtime linker, linking whatever drivers it needs at bootup. but everything will be separate files so no recompiling the kernel will be required to change drivers etc.
-- Stu --
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:The Holy War: Monolithic vs. MicroKernel
just for the fun of mentionning it, MacOS X actually uses a BSD kernel that runs on top of the Mach microkernel ...
I think this is the best evidence we have today that microkernels are viable
I think this is the best evidence we have today that microkernels are viable
Re:The Holy War: Monolithic vs. MicroKernel
Tim, wasn't generalising the whole point of this thread? Anyway, I agree with most of what you say, except that I disagree with 'structure has nothing to do with it.' It is arbitrary, but for the sake of disambiguating this, the line is drawn in separately compiled modules that run somewhat independently, like you say, user processes. The monolithic kernel is a fat blob of procedures in each others' pants, like I said, and the microkernel expels as much as possible into separate processes. That's pretty much what you said. Also, Minix is not a blob of globals in the sense of a monolithic kernel. It pushes out as much as possible into runnable, schedulable tasks. I see your point about the arbitrary distinctions, but this IS structure. It's all a matter of interpretation, and this is how it's interpreted, according to Tanenbaum anyway.
Re:The Holy War: Monolithic vs. MicroKernel
Thanks for all your replys!
One other question though; what kind of kernel does FreeBSD, NetBSD, OpenBSD, Win2k and WinXP have?
One other question though; what kind of kernel does FreeBSD, NetBSD, OpenBSD, Win2k and WinXP have?