For a fair number of people not accustomed to the operating system concept of a kernel, installing a Linux, BSD, or Hurd based distributions typically involves crossing your fingers and hoping that the installer can detect all of your hardware properly. If you’re unlucky and something isn’t working, you’re likely to spend some time browsing forums and following how to’s in hopes that you find something that makes your device works. In this article, I want to give an overview of what a kernel is and how you can use this knowledge of kernels to further your understanding of kernels and operating systems as a whole.
First, I think that defining ‘kernel’ is a good place to start. A kernel is the heart of an operating system. It is the chunk of code that decides how the computer’s resources are allocated, and how to interact with the actual hardware. It is a hardware specific code base that allows for the software abstractions that we rely on so heavily. For instance, when you want to play sound through your speakers, your audio program talks to the kernel and the kernel, in turn, takes what it knows about the sound board (through the sound board’s driver) and is able to produce the sound that you want played. First I will discuss approaches for writing a kernel, then I will delve into specific types of kernels in use everyday.
Types of Kernels:
Monolithic Kernels — Monolithic kernels keep all of their code running in the kernel or superuser space. Many modern monolithic kernels do allow for dynamic loading and unloading of specific ‘modules’ or chunks of code that allow for added features. Hardware is typically accessed via abstract software calls from the userspace. Monolithic kernels are the oldest type of kernels and are time tested as effective and useful in real world situations.
Microkernels — Microkernels aim to keep as little running in the superuser space as possible, and have as much running in the user space as possible. The actual kernel is the only thing that runs in kernel mode, all the drivers, file systems, and user space code is ran in the user space. This allows for a smaller, more managable code base tha monolith kernels are, as monolithic kernels increase in code base size as the need for more and more drivers arise. IPC, or interprocess communication is heavily relied upon to keep the various chunks of code talking to each other and keep the system synchronized.
Exokernels — Named after a kernel developed at MIT, exokernels are based on the premise that the programmer should have as much control over the hardware as possible, by removing abstractions commonly found in monolithic and microkernels. Exokernels ensure that resources don’t conflict in any way with each other, but let the system programmer design how the hardware functions. This type of kernel allows for experimentation in kernel algorithms, as writing, say, a new CPU time handling library is extremely easy compared to rewriting a monolithic kernel’s CPU scheduler. A major drawback is that programs are indeed harder to write, as programmers cannot lean on abstractions of hardware to make their life easier.
Hybrid Kernels — These kernels don’t typically fall into any particular category but combine specific elements from the aforementioned kernels.
Existing Kernel Projects:
Linux — By far this is the most popular open source kernel in widespread use today. It was a project originating in the early 90’s started by Linus Torvalds (“Linus’s UNIX” turned into “Linux”). It is a monolithic kernel and has active participation and contribution from thousands of developers. Linux allows the loading of modules into the kernel, which allows for dynamic loading and unloading of device drivers. It is based on UNIX computing concepts. Driver support is generally considered good, although getting hardware drivers to compile and work without any kernel experience can be somewhat confusing to those unaccustomed to the process and consequently many people have the opinion that Linux has worse driver support than Windows. In fact, Linux is more likely to work out of the box than Windows, as the Windows kernel has bare minimum drivers to get the system to boot upon installation, whereas Linux has many drivers built in. Linux is renown for its stability and wide usage in everything from handheld phones to supercomputers The latest release of the Linux kernel at this time is 2.6.23 and is freely available from here. Take note that the kernel aquired from this site is a ‘vanilla’ kernel. Distributions like Ubuntu usually distribute kernels modified from a vanilla kernel typically to expand upon out-of-the-box driver support. Linux has proven itself a very reliable kernel and is commonly used in industry.
MACH This was a research project at Carnegie Mellon University that lasted from 1985 until 1994. The Mach kernel (and its derivatives) is probably the most successful microkernel still available. Although contribution from Carnegie Mellon ended with Mach 3.0, many other projects still exist to continue the work on this project. The Mach kernel was designed to replace a UNIX kernel with little or no hassle. Drivers are ran in the userspace (typical of a microkernel), so much of the computational lifting that a kernel like Linux does is moved into the user space. The biggest problem with the Mach kernel is the overhead processing time consumed by its IPC (Interprocess Communication System) task handling system. In this system, a task would ask the IPC for a port in the kernel to handle its process. Although at face value this might sound like a workable system, performance was severely hampered and Mach was indeed more computationally expensive than UNIX. This kernel, although not very actively developed today, Mach gave rise to kernels such as XNU (used in Mac OSX) or L4, and remains important in studying kernel architecture.
BSD — Also known as the “Berkeley Software Distribution”, BSD was developed at the University of California Berkeley as a UNIX variant in the 70’s. The BSD kernel is rich in history, and has several popular derivative distributions such as FreeBSD, Dragonfly BSD, and NetBSD. Being a descendant of UNIX, it is largely a monolithic kernel, and is considered very stable.
HURD — The Hurd kernel, found in GNU/Hurd systems, is the kernel that the GNU foundation has developed. The GNU project began in 1984 and quickly implemented many of the basic tools an operating system needs to function. However, work on a functional kernel did not begin until 1990. The kernel was based upon the Mach kernel, but code difficulties caused the progression of the Hurd kernel to go slowly. This gave the far more usable Linux kernel to take the place the Hurd kernel was supposed to fill and allowed for GNU/Linux systems to emerge and rise in popularity far faster than GNU/Hurd systems. The Hurd kernel, being based on Mach, is a microkernel, and the most popular distribution is Debian’s Hurd Port. I myself find the Hurd kernel extremely interesting and have broswed through the code in hopes to find a way to help out with the project. In its current state though, the Hurd kernel still has work to be done before it is considered to be an enterprise class kernel.
XNU — More commonly called “the Mac kernel” XNU stands for “X is not Unix “. Although originally developed from the Mach kernel, the XNU kernel has adopted monolithic approaches as well as microkernel approaches in its evoloution, and is commonly considered a hybrid kernel. The XNU kernel borrowed much of the memory management as well as the thread and process management from the Mach kernel. Large chunks of code were taken from the FreeBSD kernel to provide implementaion of user and group support, POSIX implementations, the networking stack and the IPC tools. Nowadays, it is closed source and used in Mac operating systems.
Windows: (Although this is an open source blog, I will try to be fair with this paragraph 😀 ). Although this kernel is naturally closed source and owned by Microsoft, the Windows kernel is generally considered to be a hybrid of some sorts. It is indeed the most popular kernel on the desktop in the world. Not based upon UNIX computing concepts, it has a strange notion of userspaces and permissions (to me at least), which contributes to the platform’s problems with being riddled with effectively dangerous malicious code. The Windows kernel has also been criticized for blurring the boundaries between the kernel space and the user space. For instance, certain programs, like IE are so closely integrated into the system that they are often considered part of the kernel. Furthermore, the latest of version of Windows (Vista) requires astronomical amounts of resources to operate that challenge the limits of 32 bit computers. The close marriage of the userspace and kernel space, combined with the poor notion of permissions, and the closed source, exclusionary nature of the kernel and the resource hungry demands are the reasons why so many programmers dislike the Windows. Say what you will about the technical aspects of the system, with the help of Microsoft, Windows gained the largest market share on the desktop and remains important for a typical computer user. I personally hope that open source kernels and open source operating systems bypass Windows in the near future in market share.
I hope that this article helped to enlighten you about the types of kernels and illustrated a little bit of software history. This just barely scratches the surface of what a kernel is, so if you want to be an expert on kernels, more research is definitely needed! Feel free to browse Wikipedia or other sources for more information about kernels if you have found this interesting! The kernel is a low level concept that is critical in understanding the nature of a modern computing environment. Check back soon for an article on how to specifically deal with compiling, troubleshooting, and even writing for the Linux kernel!