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.