Apple’s Darwin operating system is the Unix-like core underpinning macOS, iOS, and all of Apple’s modern OS platforms. At its heart lies the XNU kernel – an acronym humorously standing for “X is Not Unix.” XNU is a unique hybrid kernel that combines a Mach microkernel core with components of BSD Unix. This design inherits the rich legacy of Mach (originating from 1980s microkernel research) and the robust stability and POSIX compliance of BSD. The result is a kernel architecture that balances modularity and performance by blending microkernel message-passing techniques with a monolithic Unix kernel structure. We’ll go through a chronological exploration of Darwin and XNU’s evolution – from Mach and BSD origins to the modern kernel features in macOS on Apple Silicon and iOS on iPhones. We’ll follow this with a deep dive into the architectural milestones, analyze XNU’s internal design (Mach-BSD interaction, IPC, scheduling, memory management, virtualization), and examine how the kernel and key user-space components have adapted to new devices and requirements over time.
↫ Tanuj Ravi Rao
Despite its popularity and open source kernel, it’s quite rare to see detailed deep-dives into the underpinnings of macOS. It always surprised me that nobody took whatever Apple threw across the fence every macOS release and ran with it – much further than “run existing open source desktops but worse” we never got when it comes to Darwin distributions (although this might change) – so perhaps having more approachable articles like these out and about get people interested.
The lost opportunity for Apple was not to make a server operating system out of this.
They already had a server OS & discontinued it around the time that they discontinued their server offerings.
I know that. But it was limited, for smal offices and things like that. I am talking about competing with Linux in all fronts, not necessarily on Apple hardware. To eat a slice of the server market but most importantly, to turn Macs in the de facto development environments for all of that.
Linux is free. You’re going to have a hard time competing against that…
If Apple made a “MacOS Server for generic PCs”, there was the risk (or should I say the certainty) that people would use it on generic PCs (instead of buying Apple’s computers). In plain English, it would require Apple to provide a version of MacOS that boots on generic PCs without modification and commit to a hardware compatibility list.
Just because you and I wanted to see something like that, it doesn’t mean it would benefit Apple’s bottom line.
They could provide it without the graphical parts.
jgfenix,
They could, is macos really that compelling without the graphical parts? After all tons of linux developers use a macos desktop to work on linux services. If you take away the desktop, then you might as well be running linux. I could be wrong about the demand, but that’s my opinion. Apple has a marketing advantage with consumers, but those same consumers don’t care about back end systems where apple don’t have an advantage over FOSS. Given the fact that apple dropped their server line, I suspect that even they feel the same way.
alfman,
Not particularly, no. There are better Unix-like server OSes out there.
An Apple RPi competitor running Darwin might be interesting as a throwback to the Apple ][, but it probably wouldn’t be more then a toy.
@Flatland_Spider
What does the Darwin kernel have to do with the Apple ][ though? I mean, it would be better just to boot straight into an emulator.
I found one:
https://github.com/FZBunny/applepi
It runs on Linux.
People tried and what they found out is that a kernel tuned for interactive latency is bad as a server OS. Apple realized this themselves and have a bunch of Linux servers powering iCloud, etc.
Apple really should have bought Red Hat and kept RH as an independent subsidiary. RH could have built a management ecosystem and made sure macOS is a first class platform in the ecosystem.
Huh.
Given the amount of code that Apple lifted from the BSDs, it would be nice if Apple pumped some of their huge stashes of cash into the BSD foundations. Heck, even Blackberry was a donor …
https://freebsdfoundation.org/our-donors/donors/?donationYear=2024
Sure — Apple might have contributed back to the code bases, but then so did Netflix.
>”It always surprised me that nobody took whatever Apple threw across the fence every macOS release and ran with it – much further than “run existing open source desktops but worse” we never got when it comes to Darwin distributions (although this might change) – so perhaps having more approachable articles like these out and about get people interested.”
Every benchmark I’ve seen for many years has shown that Apple OS’s perform worse than the competition, even on Apple’s own hardware. So it’s not really surprising that almost no one wants to use Darwin as a base for developing another OS. Other source code is more freely available, works with vastly more hardware, and performs most tasks faster. Which makes Darwin a lose-lose-lose proposition. I wish these hobbyists well in their pursuits, but they are not likely to gain much of an audience. Apple’s success is in its branding and marketing, not in its kernel performance, file system performance, etc.
Darwin/macOS is tuned for latency not throughput, and latency isn’t what they were testing.
It’s a great OS for interactive use (desktop, laptops, mobile, tablets), and a bad OS for server use.
Desktop performance is horrible from everything I’ve seen. File system performance is awful. You can take any Mac hardware and install Windows or a GNU/Linux distro on it and improve the performance significantly.
I’ve never felt desktop performance was a problem with macOS, and I’m probably the bottleneck with whatever desktop OS anyway.
I run Windows, Linux, and macOS daily. They’re all fine as long as the hardware isn’t total trash; then, Linux works better.
That was a great read – thanks.
probably true for servers. I don’t know. I do know the experience seems like the opposite when you take a bogged down windows installation, and turn it into a hackintosh . Then it seems to stay snappy with the same amount of software installed. Probably more of a window bloatware thing.
There were some interesting uses of the source in the early hackintoah days like the voodoo kernel, where they added support directly into the kernel for hardware that Apple never supported.
I was always surprised as well that Apple Open Sourcing their kernel did not cause a bigger Open Source response. My gut instinct was that somebody would grab it, put GNUstep on top, and create an Open Source macOS clone in short order. Nope.
Why has the Darwin kernel not been a catalyst for Open Source innovation? A big hint can be found in the FAQ of probably the most viable macOS clone attempt–RavynOS (see Why BSD instead of Darwin?):
https://ravynos.com/faq
The short answer is “hardware support”. They are choosing to make a macOS clone on top of FreeBSD instead of Darwin because of “hardware support”. Let that sink in. When has anybody ever chosen FreeBSD because of “hardware support”. As a Linux user, I would say that is the main reason not to use it.
But it makes sense. While Apple did Open Source much of their OS, they did not include most of the drivers for Apple hardware or third-party hardware. If you look at Linux, more lines of code are for drivers than anything else. Even though Apple Open Sourced the kernel and much of the userland, a lot of the work required to make a viable operating system still needs to be done.
Another big factor is that the kinds of people that are attracted to macOS are not the kinds of people that value less functional Open Source replacements. So gaining ground with the crowd most compatible with the code Apple contributed would be a long road. That has probably been the issue with GNUstep as well. Despite efforts to pivot, it has been more of a continuation of the NeXT APIs than a real alternative to Apple. Hopefully that changes.