DæmonNews: News and views for the BSD community

October 2000 Get BSD New to BSD? Search BSD Submit News FAQ Contact Us Join Us
Search


Get BSD Stuff

Introduction to Darwin

by Rob Braun <bbraun@synack.net>

There has been a fair amount of hype over Darwin and MacOS X recently, but they have largely been treated as nothing more than a curiosity by the BSD community. Most people I talk to about Darwin either don't know what it is, or say "Oh yeah, that's the MacOS X thing, right"? This article will give you a brief introduction to Darwin, why it matters, and how Darwin differs from the rest of the BSDs.

Darwin is the FreeBSD/Mach derived core of MacOS X. This is the definition that has been pasted next to Darwin all over the web, but what exactly does this mean? Darwin is based on Mach 3.0 and FreeBSD 3.2, and glued together in a very NeXT-like style. A variant of the Darwin kernel and userland utilities make up the core portion of MacOS X, but Darwin is very much a standalone OS in its own right. There is a binary installer for Darwin, all the standard user utilities, and XFree86 has also been ported. By all accounts, Darwin is a full fledged standalone operating system.

What is the difference between Darwin and MacOS X? Darwin is basically the command line only version of MacOS X. Darwin's kernel is the development version of MacOS X's kernel (minus a few proprietary drivers). If you stripped off the GUI and all related programs and libraries from OS X, you've got Darwin. The source to everything under Darwin has been released under the APSL.

Why would anyone want to work on Darwin? Darwin is controlled by Apple and is part of a commercial product, so why invest your time and effort in it? There are advantages and disadvantages to working with a project that is controlled by a company. One of the very large advantages, is there are many people working full time on this project. One of the disadvantages is that if they don't like your ideas, they win. However, this is not unlike the development model that the current BSDs use. There is a core team of developers, and changes to the CVS repository must be approved by one or more of these core developers. If you're not one of these core developers, and the core developers don't like your idea, they win. So, it's not all that different from working on one of the other BSDs.

The most obvious reason people want to use Darwin is to get a feel for MacOS X before it is released. This can include developing drivers for MacOS X before it's released, or just to play with it and get used to the idiosyncrasies before having to work with MacOS X. This is the most common reason for people to use Darwin.

Darwin is also a BSD that works on Macintosh hardware, and is the only reasonable choice for some of the newer Macintosh machines. Most of the hardware shipped by Apple is supported and will be supported, and you don't have to worry if that driver author will have enough time to work out that bug this weekend. This is a very motivating reason to run Darwin for many people. The hardware support and interoperability with MacOS is very helpful.

However, the most interesting reason to work on Darwin is that Darwin maintains BSD compatibility, but takes a different approach at problems than the traditional BSDs. BSD has been around for several decades now, and has not significantly changed. There is of course ongoing development, porting to different architectures, adding features, but the fundamental aspects of BSD have not changed. For example, FreeBSD has done work on supporting loadable kernel modules, but very slowly and great pains are being taken to have a minimal impact on the overall design of the kernel. Darwin has taken a much more radical approach; there has been a huge impact on the overall design of the kernel. Each approach has its merits, and especially at this point it is impossible to say which is "better", but it is very interesting to see the differences and how each progresses.

So, what distinguishes Darwin from the other BSDs? What is Darwin's niche in the BSD world? Darwin has no "gimmick" to distinguish itself from the other BSDs, like OpenBSD's "more secure", and NetBSD's "more portable" gimmicks. The closest thing to Darwin's gimmick is "the core of MacOS X". However, there are huge differences between Darwin and the other BSDs, both in the kernel and in the user space.

I've said before that Darwin is derived from Mach/FreeBSD with a NeXT flavor. Despite the integration of Mach, Darwin is not a pure microkernel OS. All other portions of the kernel share address space with Mach. This prevents the performance hit when other portions of the kernel wish to communicate with Mach. It also allows for a tighter integration of all the components of the kernel.

In addition to the Mach and BSD components of the kernel, the driver interface is through a component called IOKit. IOKit is an object-oriented driver interface model. Unfortunately, this means that all of the existing BSD drivers must be ported over to IOKit before they can be used by Darwin. However, this provides a number of features that the existing BSD driver interface lack. With IOKit, potentially every driver, and class of driver can be dynamically loaded and unloaded. The object oriented nature of IOKit also reduces redundant code and simplifies driver development. The driver interface is explicitly laid out for you, so new developers have an easier time understanding what is required of them by the driver interface. I'm not much of an object-oriented programmer, but I find IOKit to be exceptionally cool.

So, the five second rundown of the relationship between all these different components is that Mach provides the virtual memory environment and much of the machine dependent boot code. IOKit provides the drivers for all the various devices. And BSD provides the interface to all these things, such as the filesystems, system calls, and virtually everything a user land application needs access to. This is a gross oversimplification of the relationships between the components, but should give you a vague notion of how things fit together.

At its heart, the user land environment is very similar to the other BSDs. You still have /etc, /bin/sh, and everything else to make you feel secure on a BSD machine. However, Darwin takes a different approach at managing many of the mundane tasks of the system. Like the old NeXT machines, Darwin uses NetInfo for much of the system configuration, such as user information and resolver configuration. The goal being to have a centralized database of host configuration information rather than numerous flat files distributed throughout the system. For those users that prefer the traditional way of doing things, it is completely possible to kill off all the NetInfo services and still use /etc/passwd, /etc/resolv.conf, and so on. Personally, I find the NetInfo interface clumsy and difficult to use, so I have chosen for the NetInfo-free Darwin configuration.

Darwin is a BSD with radical deviations from the traditional design. These deviations are both its strength and weakness. Even if you don't run Darwin, there is a lot that can be learned just from watching Darwin's progress.

The true test for Darwin's viability as a standalone operating system is coming in the not too distant future. Many of Darwin's current users are using Darwin as a preview to MacOS X. How will Darwin fare once MacOS X is released?

For more information on Darwin, please see Darwinfo.

Darwin can be downloaded from Apple.




Author maintains all copyrights on this article.
Images and layout Copyright © 1998-2004 Dæmon News. All Rights Reserved.