Friday, January 18, 2008

Linux vs. Windows vs. OS X - The Kernel Debate

Let's talk about the underpinnings of an operating system. At the heart of all operating systems is something you may have heard of called the kernel. The kernel is the true brains of the OS and controls virtually all aspects of interacting with the underlying hardware. Basically without this essential component of the operating system your computer would just be an expensive paperweight with spinning fans.

There are two main approaches in regards to kernel design The first of which is the monolithic kernel. A monolithic kernel is one in which the entire kernel exists as one large file. The second approach is known as the microkernel. An OS built on the microkernel approach will have many smaller kernels that all communicate with each other.

Proponents of the micro approach make the case that the kernel becomes simpler when you split it up into smaller parts. In general, the kernel is a very complex body of code. (Many would say that is an understatement of Biblical proportions) The general idea is that you can make a very complex project much more palatable by breaking up its parts and working on those individually. In contrast, proponents of the monolithic approach argue that microkernels actually become more complex and have more exploits simply because the communication between all the parts becomes harder and harder to deal with as the kernel grows. They argue that the kernel should be treated as one entity so as to avoid this type of intricate communication network.

So, let's take a look at the 3 major desktop operating systems out there and find out what they are running under the hood.

Windows
With the development of Windows NT, the operating system moved to a microkernel approach. This means that Windows NT, 2000, XP and Vista are all based on a type of microkernel. In fact, NT was based on the MACH kernel, which was a microkernel project out of Carnegie Mellon University that was supposed to be the answer for all operating systems.

Mac OSX
Since the introduction of OSX Apple moved to a kernel based on an open source BSD kernel. In fact, this kernel takes a microkernel approach and is actually based on, yep you guessed it, the MACH kernel. The move was praised by many and in fact, I feel that it was the best move for the Mac.

Linux
Linux stands out from the other two in its monolithic approach. The Linux kernel is one large file that is made up of over 5.9 million lines of code. In fact, almost all of the hardware drivers are contained in the kernel itself. This makes installing "drivers" in Linux a non issue. Most hardware simply works out of the box.

As you might have guessed from the title of this blog, I personally endorse the monolithic Linux kernel to the other two. Specifically, the kernel design in Linux can be attributed with much of its many benefits. The monolithic approach that Mr. Torvalds has architectured scales, adapts, and performs surprisingly well. In fact, a big argument against microkernels has always been performance. Modern microkernels have become incredibly complex as they deal with new hardware and environments. This makes them more difficult to develop in my opinion. Every time a new piece is added to the kernel, the communication network that interconnects it to the rest of the pieces becomes exponentially more complex. This can many times lead to more security exploits as well as performance issues.

I hope this post can help people out there understand a little bit more about kernel design and the similarities and differences between the major operating systems.

7 comments:

Alastair Gould said...

Where does it say NT is based on mach?

Its a hybrid kernel, which really monolithic kernel, but with some modularized code. Its really monolithic.
I"m guessing its the way they handle drivers, that makes it a hybrid approach. So if the driver crashes, the kernel doesn't.


OS X is based on XNU which is hybrid, but takes some elements out of mach, and the classical bsd kernel. Its really monolithic, with some micro kernel approaches. Guess what micro kernel ideas apply to? the I/O Kit, for making drivers. So the drivers don't crash the os. Really its monolithic

Linux is the same a monolithic kernel, but with some micro kernel approaches. Guess where? Drivers

http://en.wikipedia.org/wiki/Linux_kernel#Loadable_Kernel_Modules_and_firmware

Its just Linus like me does not like the term hybrid. There really just monolithic kernels. So he calls it monolithic like they should.

http://en.wikipedia.org/wiki/Hybrid_kernel#Opponents

Alastair Gould said...

Its very early in morning, so excuse my grammar in the last post. But you get the idea :P

Alastair Gould said...

Also you could say linux is based minix. Guess what that is? Microkernel

Michael Taggart said...

Alastair,
Thanks for the comments. I found a page on the web that talked about NT coming out of MACH, but am having a hard time refinding the link. You are very right about the hybrid approach. I should have defined that in my post.

You are right in that Linux came out of Minix, but Linus specifically avoided the microkernel approach of Minix because he thought it was "stupid."

Ben J said...

Alastair, isn't OS X's kernel XNU, which is based on BSD and Mach. Then the collection of the kernel and other features collates to form Darwin.

I don't think OS X is based on XNU.

Anonymous said...

All of these OSes suck.
I wonder why people endorse ANY of these crap-ware.

Personally, I use Windows, only because it has some common sense in its UI/shell/philosophy (while others don't) and because it has the best IDE and developer tooling (while the others don't). Also, apart from some penetration testing tools that Linux has, I think Windows has tools that other OSes couldn't even imagine. And despite the fact that I am an experienced user, doing things the Linux way (or the MAC way for that matter) makes me sick. And, to be honest, I don't like the people in Apple nor Linus and his followers (I don't know why, just there's sth on them that I just can't embrace - even compared to the somewhat-genocidal Bill Gates).

Apart from that, I know Windows is not so great and I do have all other OSes hosted in VMs. I open them from time to time, only to see how a world without Microsoft would be... And I am not thrilled with the idea...

I will not even bother with performance or security, although and since I never had virus/spyware/hack issues on Windows7, nor a performance issue that came from Windows it self. And seeing that people choose Windows even for their server, while Linux was specifically built for servers, makes me wonder where Linux has fcuked up itself so much.

But I do use Linux and it is good for many jobs.
While I don't seriously use Mac OS and probably never will. :P

I just wish someone made a brand new OS that had no code in common with the existing ones.

DeusExMachina said...

Mach is not based off BSD.