Post a Comment
Well Microsoft Windows Vista may not be a microkernel, but it is doing a lot of simular things and I think that is great.
Most of all the drivers are now in the UserMode and 64-bit Vista has a different core even. I think Microsoft is moving in that direction starting with Vista and even in 64-bit mode they are moving even faster in that direction.
o Drivers can crash and not crash the OS (just restart and go). Vista may be able to restart automatically.
o Drivers can be upgraded without rebooting.
o Drivers can be easier to create(program) in usermode.
o Drivers can be easier to test in usermode.
However, I think the circumstances have changed a lot since those days. Monolithic made sense 16 years ago, but with today's powerful computers with processors acting as $300 dust collectors most of the time, the advantages of a muK simply outweigh its inevitable, minute, and in user experience probably immeasurable, performance hit.
IIRC, the reason OS X is measurably slower at some tasks is because of the microkernel factor. (I seem to remember some sort of kerfluffle about X serves and SQL queries.)
But, on the other hand, there is the legendary stability of QNX.
(in the Netherlands, we say, 'automatic is for women'; no offence to the USA where automatic gearboxes are much more popular, since you guys across the pond have longer distances to cover)
Y'know, that statement really implies that women are inferior. Next time you see a guy push a small person out of a tight orifice, let me know.
And the reason we have so many automatics over here, is that the US generally has non-existant public transportation, which makes for long slow commutes, and 90 minutes of stop and go with a manual gearbox will have your left knee screaming in pain.
(BTW, I drive standard transmission.)
it's why I prefer a straight Martini Bianco over weird cocktails (again, the end result is the same, but I'll leave that up to your imagination)
"Where are my clothes?! Wait. Whose bathtub is this?"
IIRC, the reason OS X is measurably slower at some tasks is because of the microkernel factor. (I seem to remember some sort of kerfluffle about X serves and SQL queries.)
OSX is not a true muK by academic standards. It is a "modified microkernel" (in much the same way as the Windows NT kernel is, which is also sometimes mislabeled as a muK). It does not at all work the way Thom's article describes, as the BSD server makes direct function calls into the kernel and does no message passing at all. It is for all intents and purposes a monolithic kernel.
If your interested in how OSX is designed under the hood, read the paper at the following url:
http://www.usenix.org/events/bsdcon02/full_papers/gerbarg/gerbarg_h...
"Where are my clothes?! Wait. Whose bathtub is this?"
Nah, Martini's different. More like: "Thom, did we really get kicked off of a graveyard last night?" "Yes..." while thinking, thank god girl you didn't mention that other thing in front of this 30-man crowd that together composes my social life...
:/.
RE: OS X, QNX, and Tomfoolery
Someone/something has to do the hard stuff. Imagine a userspace driver, which doesn't crash, but for some reason writes garbage to your screen. It can't get automatically restarted, because from a microkernel POV everything is in best order. So you either have to restart the server using a remote machine (and hoping that the NIC driver is fine) or simply reboot. I'd say most users will go for the second option.
So - a buggy driver in userspace isn't much better than a buggy driver in kernelspace.
But yes, I agree, writing drivers in userspace is probably way less difficult than in kernelspace; that's probably the single most important difference.
There has been talk in nanokernels of making the scheduler user-space to so that different apps could use different schedulers. For example there could be problems with not being MP-safe so you'd want to have finer control, or some legacy code that makes certain exceptions, or a myriad of other reasons.
The timer has to be in the kernel. How else would the scheduler function?
Cooperatively? Don't laugh. That's an option and if you can plug-in various schedulers it could be useful, especially for something like Wine emulating Windows 3.11, or if you have some real time (RT) tasks and non-RT. Where you could put the on-RT scheduler as a process with the RT-scheduler.
I don't recall where I read this, but I believe it was in some paper on a branch of the L4 project.
The problems with microkernels is than, in theory, they really look good. However, in practice, running a file system in user-space adds no benefit: if it crashes, how can you restart it? If the memory manager bails out, how can you create a new process and allocate memory for it? The networking subsystem is a good candidate for a user-space subsystem, but what about a diskless-workstation that boots from an NFS export? What would happen if the networking subsystem crashed?
More and more pieces of Linux are being pushed out to userspace. One nice example is used, of FUSE. udev is a central place in Linux device management, but even if it crashes or malfunctions, you can revert to the well-known mknod tool.
file system in user-space adds no benefit: if it crashes, how can you restart it?
I don't see the problem. Just restart and block and process that makes an I/O until it's back a running.
If the memory manager bails out, how can you create a new process and allocate memory for it?
Kill any process allocated by that manager, but any app controlled by another can continue living. You could make an ultra-stable manager for essential functions, and a more powerful-but-complex-so-harder-to-debug one for user apps.
what about a diskless-workstation that boots from an NFS export? What would happen if the networking subsystem crashed
Well it could run off the data it has in memory and/or just block until the connection is re-established. You could have a process that stores the details of your account monitor the connection process, and when the connection dies have it refeed the data that is needed to regain passwords.
I don't see the problem. Just restart and block and process that makes an I/O until it's back a running.
Usually, restarting a process involves reloading the binary from disk, so if the file system is just to get restarted, how can you load it back from disk to memory? You could keep its text in memory, but what about corrupted data structures?
I still don't see any advantages of a microkernel system. Just look at Windows NT 4.0 and how they integrated back the graphic drivers back into kernel space due to performance problems. The fact is that, in Windows NT 3.5, a crash in the graphics subsystem left the system unusable. Well, it could keep serving files, but it was impossible for anyone to log in to the system.
There's a misunderstanding here. The fault handling that supposedly comes from microkernels isn't keeping the failure of a component from causing the system to fail. Rather, it's keeping the failure of a component confined within that component.
All microkernels do, from an architectural point of view is enforce fault confinment through the use of seperate address spaces.
The problem is that the cost they introduce to provide that separation is higher (usually *much* higher) than the benefit gained.
Some notes:
The "clock" is probably a source of periodic interrupt used by the scheduler for pre-emptive task switching and timing (things like a "sleep()" function). It probably has nothing to do with "time and date". Because the scheduler relies on this clock (and everything else relies on the scheduler instead of this clock), building support for it into the microkernel is a very sane thing to do.
A micro-kernel is not necessarily "fail-safe". For example, if the hard disk driver crashes then you'll loose all of the data stored in swap space, and having a micro-kernel won't help to retrieve it. Another example would be the virtual file system - if it crashes then any software that was relying on it will loose their open file handles, etc. The same applies to everything that retains "client state". With a lot of work a micro-kernel can be more "fail-safe", but you need systems in place to take care of each type of failure. Without these extra systems it's not much better than a monolithic kernel (of course "protection" is a different subject).
I have to agree with felipe_alfaro. On technical merits alone, microkernels stomp monolithic kernels into the ground. In practice (and code) it is the other way around.
The #1 problem with the microkernel design... can we say latency? With any microkernel, the latency issue is horrendous. XNU, the kernel in Mac OS X, doesn't have as much of a latency issue because it is more hybrid than minix 3 or L4. I guess this makes XNU more of a hybrid microkernel, but not even minix 3 is 100% microkernel based. Scheduling and race conditions can also be more of an issue in microkernels as everything runs in userspace.
http://www.minix3.org/vmware.html minix 3 vmware player image
I have to agree with felipe_alfaro. On technical merits alone, microkernels stomp monolithic kernels into the ground. In practice (and code) it is the other way around.
When you say in practice are you refering to those of AmigaOS, MorphOS, AROS, QNX and many others? I always liked best the idea and practice of micro kernels
I am politely saying that Linux which is a monolithic kernel, beats every supposed microkernel I can personally find. Andrew Tannenbaum (whom I deeply respect) says microkernel design is better and I don't disagree with him. However, his code (minix 3) is still inferior from many angles versus the Linux kernel. Is there a microkernel that even matches the Linux kernel performance wise?
I somehow doubt I will ever see a microkernel that will come close to the speed of RTLinux (realtime linux).
I am really trying to not start a flamewar here.
Oh joy. Here it goes again - the ever lasting story of how never-succesful academic bullshit called "microkernel" never made it into the mainstream OSes. And how world would have been a safer place, with no drivers fooling around in ring0, if Cutler/Torvalds/whomever had listened to mr. Tanenabaum and alike.
The microkernel propaganda is mostly composed of three common FUDs:
1) microkernels are more "stable", because having ALL kernel code besides scheduler/dispatcher, IPC and some basic interrupt routing in ring3 (aka user-mode)
WRONG. If any crucial OS component (such as Memory Manager or FileSystem driver) fails - the whole OS fails as well. Being in ring0 (like the monolithic kernels do it) makes it just crash faster.
2) microkernels are more modular/maintanable/simple/blahblah
Writing modularized code is the basic tenet of software engineering, and it's called separation of policy from mechanism, and has NOTHING to do with the kernel being monolothic or not.
For example - Linux kernel is highly modular, either from the standpoint of compile time flags, or dynamically expandable functionality via LKMs. Just look at the design goals behind the VFS(used by any filesystem driver) and LSM (Linux Security Modules - utilized by SELinux, DTE..) to know what I mean..
NT kernel (W2K, WS2K3, XP, Vista..) is also very modular - the basic kernel schedulable primitives are encapsulated into so-called "executive components" (MM, I/O, essentialy anything besides scheduler) but are still all being compiled into one big fat binary called NTOSKRNL.EXE. The point is that it's the code that separates different abstraction policies, not the postcompiled modules organization.
3) It's easier to write drivers for microkernel.
Because they should, by definition, be living in ring3, and could be debugged in gdb or VS, and not in null-modem connected kernel debugger :-) And that's the reason why printer drivers are in userland ever since W2K, why Vista will have so-called UMDF (User-Mode Driver Foundation) that will enable most, for OS nonessential, cheap hardware to have it's drivers running in ring3 (if you have XP SP2, check out the WDFMGR.EXE's process description
And the cons against microkernel? Spending most of your CPU cycles doing context switches and IPC for simple stuff such as page fault handling and ISR dispatching.. That's the reason why there are NO general-purpose commercially-successful microkernel OSes - that's right, all Win NT-based, Linux, *BSD, Solaris, HP-UX, AIX, MacOS (aka Darwin - it contains Mach but it is not used as a microkernel, there are the FBSD, IOKIT and drivers stuff in ring0 too!) are monolithic. And those who aren't, (QNX, EKA2 - SymbianOS nanokernel) are so not because of the "increased stability and security", but because it enables them to have predictable interrupt latency.
Sorry for bad english.
Please take note that ring0 and ring3 are Linux-only terms, and meaningly outside discussions of the Linux kernel only
LOL, read the Intel manuals dude - it's OS-agnostic term meaning "privilege level", and has roots in MULTICS (IIRC it had 8 od them
Besides, the NT Kernel and Mac OS X kernel aren't monolithic, but hybrid.
Wrong again - NT is even more monolithic than Linux, since it has GUI (win32k.sys) in kernel-mode. Read the relevant literature (Solomon/Russinovich for examble).
As for the MacOS - it does contain the Mach microkernel - but, as I said, it's not used as a microkernel. See what the author of upcoming "MacOS X Internals" book says on this topic:
http://www.kernelthread.com/mac/osx/arch_xnu.html
XNU's Mach component is based on Mach 3.0, although it's not used as a microkernel. The BSD subsystem is part of the kernel and so are various other subsystems that are typically implemented as user-space servers in microkernel systems.
The term "hybrid microkernel" is IMHO just a marketing propaganda dating from mid 1990s when NT 4.0 was released. NT is even more monolithic than traditional UNIXen.
Wrong again - NT is even more monolithic than Linux, since it has GUI (win32k.sys) in kernel-mode. Read the relevant literature (Solomon/Russinovich for examble).
Wowwow there, NT is a hybrid kernel. It started out as a true muK (Tanenbaum even compared MINIX to NT), but slowly but surely more things were added into kernelspace. The fact that the GUI is placed in kernelspace does not change the fact that NT is a hybrid kernel. Wikipedia has this to say on it:
"The architecture of the Windows NT operating system line is highly modular, and consists of two main layers: a user mode and a kernel mode. Programs and subsystems in user mode are limited in terms of what system resources they have access to, while the kernel mode has unrestricted access to the system memory and external devices. The kernels of the operating systems in this line are all known as hybrid kernels as their microkernel is essentially the kernel, while higher-level services are implemented by the executive, which exists in kernel mode."
http://en.wikipedia.org/wiki/Architecture_of_the_Windows_NT_operati...
And with Vista, a lot of parts are moved out of kernelspace again, back into userspace where it belongs. So when Vista comes, the NT kernel has grown more towards its muK origins.
Wowwow there, NT is a hybrid kernel. It started out as a true muK (Tanenbaum even compared MINIX to NT), but slowly but surely more things were added into kernelspace.
No, NT is NOT a microkernel, and was never designed to be one. It has
1) ring0 drivers
2) all non-essential kernel services, which are traditionally implemented as user-mode (ring3) servers in pure microkernels such as Mach, are in ring0
3) it has even super-nonessential stuff in ring0 such as GUI, traditionally in ring3 on *NIX
There is no way to communicate between, lets say, Memory Manager and the Scheduler via formal IPC (msg_send() and msg_receive() in Mach) - they are ALL inside one statically compiled nonseparable module.
Wikipedia article is somewhat clueless, and paradoxical IMHO:
The kernels of the operating systems in this line are all known as hybrid kernels as their microkernel is essentially the kernel, while higher-level services are implemented by the executive, which exists in kernel mode.
So it basically this sentence says: kernel = microkernel, but upper-level services are still ring0, like the microkernel itself :-)
But if both higher-level services and the "microkernel" are in the same privilege level, they must be in the same address space, meaning no protection, no security, no mutual IPC - ie. no microkernel design at all
As i said - calling NT a hybrid microkernel is just a marketing propaganda from the 90s, when the term microkernel was hot stuff.
Actually, it did had 8 hardware rings
http://www.multicians.org/mgr.html#ring
It's really funny that most OSes today are still being built on 1960s technology 
"Please take note that ring0 and ring3 are Linux-only terms"
Uh, no. They are operating system design terms where the actual number of rings depends on the processor.
"Besides, the NT Kernel and Mac OS X kernel aren't monolithic, but hybrid."
Agreed, and so is the Linux kernel.
And the cons against microkernel? Spending most of your CPU cycles doing context switches and IPC for simple stuff such as page fault handling and ISR dispatching.. That's the reason why there are NO general-purpose commercially-successful microkernel OSes - that's right, all Win NT-based, Linux, *BSD, Solaris, HP-UX, AIX, MacOS (aka Darwin - it contains Mach but it is not used as a microkernel, there are the FBSD, IOKIT and drivers stuff in ring0 too!) are monolithic. And those who aren't, (QNX, EKA2 - SymbianOS nanokernel) are so not because of the "increased stability and security", but because it enables them to have predictable interrupt latency.
I know, I know, that's one of the reason all *miga OSs out there feels so slow... :roll:
For example Exec is mentioned on wikipedia as an 'atypical microkernel', which is part microkernel, part hybrid.
http://en.wikipedia.org/wiki/Kernel_%28computer_science%29#...
Also, from what I've read some nanokernels with limited amounts of features do fine.
Projects like Gnu HURD are, in my humble opinion, destined to fail if they persist in aiming for a 'theoretically pure' implementation anyway; I believe hybrids to feature the best of both worlds. If you use services and modules, you can get performance, customisability, hotreloadability and overseeable complexity at multiple levels all at the same time. No surprise the kernels most used in practice feature either modules or services.
If you want performance, you'd be better off using exokernels anyway. I'm surprised this hasn't escaped from academia yet.
Maybe, but I'm not convinced: spreading the work too thin can be a pitfall of parallelisation: CPU contains cache and if a system request goes to several CPUs in a micro-kernel, there could easily be data shared between CPU increasing cache-contention, which reduce efficiency.
Schedulers tries to put related thread on the same CPU, while at the same time balancing the load, this is a tricky balance and I'm not sure micro-kernel helps here.
Yep, doing too much of something can be even worster than doing nothing.
Part for all naysayers about monolithic tree
On the other hand (at least in my simple mind)
Monolithic kernel could simply put out generic `muK` protocol handlers (drivers) that would act on and control outside drivers, like for example `muK` network adapter handle and provide complete protocol needed. This driver would need to act as protocol server and handle the pluged outsiders.
Hierarchy of Linux kernel is just a file system, nothing else. So why couldn't some drivers provide external `muK` capabilities?
Something being monolithic doesn't mean it couldn't be extended with some sub branches that would provide `muK` protocols and handling. Now, one network driver provides and can control few network cards that are in his domain. This would just control more generic domain.
But in my daily reality.
I don't miss microkernel a bit. So far NVidia driver was the only one I ever installed so far. I just buy most compatible machine that suits my needs and that's it.
A microkernel does not inherently make better use of
multiple CPUs than a monolithic kernel. Often quite the
reverse, in fact.
A monolithic kernel isn't a single "process" or
"thread" (although there can be threads that run solely
in kernel mode). The kernel is called by, and performs
work on behalf of, user processes.
Now say that we have a 16 CPU system with 1 user
process on each CPU and each one would like to allocate
a page of memory. The kernel is notified about this
allocation request somehow (via a page fault, usually),
then asks the memory manager to find a page, return it
to us.
In the Linux kernel, in the common case, all processes
can concurrently enter the memory manager, and none
will have to take a lock which blocks another, because
each can just take a page from per-CPU freelists.
In a microkernel, there would be 16 requests queued up
for the memory manager process, which runs on one CPU
and processes them one at a time. If you would like to
have 16 memory manager threads, then they can now run
concurrently, but they will still block one another
when taking IPC requests off the queue.
Actually, the memory manager *is* something that a high
performance microkernel is likely to multi-thread
and/or put a light-weight per-CPU allocator in front of
the IPC call (oops, no longer a microkernel!)
When you start talking about MPs, you have to be careful to distinguish between the two strategies of MP resource scheduling design. While it is common, especially the first time an OS is ported to an SMP to have a 'big kernel lock' and funnel all requests to a certain processor, that's an implementation detail and not an artifact of micro versus macro kernel.
No that's got nothing to do with what I was talking
about.
I just provided an example to illustrate why a micro
kernel is not inherently more SMP scalable than a
monolithic kernel.
In other words, a monolithic kernel can be just as
threaded / scalable as any microkernel.
I like the idea of an application or device that does one thing and does it well. But in the technology field, "convergence" is the name of the game. And this is partly being driven by consumers who want functionality in neat all-in-one packages rather than as separate components.
It's not always bad though. I prefer a simple mobile phone, but I can see the appeal of a phone with MP3 player and (basic) digital camera. Would you rather have one integrated device or carry three separate devices?
On paper, the microkernal design seems simple and elegant. The modular structure gives you the impression of a plug-and-play system where new functionality can be dropped in without having to re-engineer the whole OS - whether it's actually like that in real life though is another thing.
The problem is that on paper everyone's block diagram of their system looks modular and elegant. In practice, microkernels don't give you any modularity. They simply throw more of the crap outside the 'kernel' than was in it before. It's the same crap in a different bag. But now it has all the extra overhead of talking to the microkernel to get things done.
Great article.
In my experience, microkernel systems have better stability and are usually faster to general-propose operations (no really talking about automation systems, like car-building Robots' operation systems, and similar situations...), like a desktop operational system. Maybe it's the kind of standard organization that the system works around; but still in the end, better systems (talking about the practical results).
Another problem these days that microkernels help with, are licensing problems. Since binary compatibility is much easier to maintain as the kernel itself doesn't change too much. So, as the system "talks" a single language, code don't need to "touch" other (license's) code and the user don't need to worry about this kind of problems, it's easier to have everything "just working"...
I suggest the OP (and others too) read
http://fred.cambridge.ma.us/c.o.r.flame/msg00025.html





Score: 
