Core Layer

By: Mike Yocom - Revised: 2006-06-06 devin

Introduction

Hexley, the unofficial Darwin mascot

The core of Mac OS X — called Darwin — is a solid, UNIX-based system. Darwin combines the Mach microkernel with a number of BSD components. Darwin manages the computers hardware, networking, file systems, and inter-process communication. Darwin can be used as a stand-alone operating system that lacks Mac OS X's Media Layer, Application Layer, and Interface — meaning that Darwin provides all the resource management, UNIX utilities, and UNIX command line shells that Mac OS X does. Darwin is also open source, meaning that anybody interested in looking at, modifying, or expanding the Darwin source code can — providing much more frequent bug fixes, feature additions, and much quicker addition of support for new hardware.

One major advantage that Darwin has over the classic Mac OS is stability. This stability is provided by the fact that Darwin exercises a much tighter control of system resources — acting a disciplinarian and making all the running applications "play nice" with each other.


Memory Management


Mac OS X's memory management is among the best. memory management is abstracted so that applications don't know where their data is being stored. When a program needs to access or write to a specific memory space the operating system does it for the program, meaning that the operating system keeps track of what data is stored where, and which memory space belongs to which program. If a program tries accessing a memory space that doesn't belong to it, Mac OS X knows it shouldn't be doing that and denies the program's request. This increases stability because programs can no longer corrupt each others' data.

Another nice thing is that Mac OS X's virtual memory scheme is faster and more efficient than classic Mac OS. The system also only uses as much virtual memory space as is currently needed. In fact, programs are only allocated as much memory as they currently need, and are assigned more as they need it, so there's no more need to specify how much memory is allocated to a program, and then have to quit the program and increase the memory allocation because the user is trying to open an especially large file.

Processor Management


Another important resource that needs to be managed well is the processor itself. Again, because Mac OS X works as a disciplinarian and forces programs to cooperate with each other, no program can "hog" the processor — and if one program locks up it won't lock up the entire system.

This approach to multiple programs is called Preemptive Multitasking, and it works much better than the Cooperative Multitasking in the classic Mac OS, where a program decided when it was time to relinquish control of the processor to the next program. Programs in Mac OS X run more smoothly because there aren't any selfish programs preventing the others from running.

Another important technology in Mac OS X is Multithreading. Multithreading is when a program's tasks are split up into individual threads that can run in parallel. This allows individual programs to do several things at the same time, in addition to allowing multiple programs to be running. For example, a multithreaded Finder could be emptying the Trash, copying data from a CD-ROM, and searching for a file on the hard disk, and the user could still be browsing through folder, instead of having to wait for one task to finish before starting the next.

Along with Multithreading is a technology called Symmetric Multiprocessing. There's three ways to make computers that can process faster: increase the clock speed — higher MHz/GHz — use a better processor, and install multiple processors. Symmetric Multiprocessing balances the computational workload across the available processors, allowing programs to take maximum advantage of this approach to faster computing. The combination of Multithreading and Symmetric Multiprocessing allows Mac OS X to take the individual threads created by programs and assign them to different processors, allowing programs to perform more than one task quite literally at the same time — with multithreading on a single processor the tasks are still done in sequence, but the processor switches back and forth between them frequently enough that it looks like they're being performed simultaneously.

Device Management


Mac OS X also has an efficient device management system. Device drivers — be they hard disk drivers, keyboard drivers, or external Zip drive drivers — are loaded and unloaded from memory dynamically. This means that device drivers are only active when they're needed. This is especially useful for hot-swapping standards like USB and FireWire (IEEE 1394), where devices are supposed to be able to be plugged in, unplugged, and swapped around while the computer is running.

The I/O Kit system also makes it much easier to develop Mac OS X drivers, which removes one of the hurdles for companies trying to make their products Mac-compatible.

Networking


Mac OS X uses BSD's networking infrastructure, which allows network protocol stacks to be dynamically loaded, like the device drivers. This means that future network protocols could, in theory, be installed on a computer and loaded without needing to restart. It also means that if a computer isn't connected to the network, resources won't be wasted on keeping a TCP/IP stack in memory.

Mac OS X supports Apple Filing Protocol (AFP) — which it inherited from the classic Mac OS — and Network File System (NFS) — which it inherited from UNIX — as well as the SMB/CIFS protocol used on Windows file servers, WebDAV — an extension to the HTTP standard used for web pages that allows a computer to mount file servers anywhere in the world just like they were on the local network — and Rendezvous — a protocol for dynamic network resource discover so users don't have to memorize IP addresses or DNS names. In fact, Mac OS X computers can not only connect to servers using these protocols, they can also function as servers for these protocols. So an admin could set up a Mac OS X computer as a SMB file server and Windows computers can connect to it just like if it was a Windows server.

Internet


In addition to advanced networking options, Mac OS X supports some very advanced Internet options.

Apache — the free, open source, web server technology that runs more than half of the web servers in the world — is included with Mac OS X, so a Mac OS X computer can be turned into an Apache-powered web server with a single click. Mac OS X also includes the standard, UNIX utilities for Telnet — a remote login protocol — Perl — a cross-platform programming language commonly used on the internet — and FTP.

Mac OS X is also a multihoming system. This means that Mac OS X can send and receive data through all of its network interfaces at the same time. It also means that portable computers can be connected to a wireless or Ethernet network — be it at campus or at work — and then taken home and connected to a modem, and Mac OS X will automatically switch to the appropriate interface.

The Real-Time Protocol/Real-Time Streaming Protocol (RTP/RTSP) for streaming video are supported by Mac OS X. Lightweight Directory Access Protocol (LDAP) for online directory services is also supported.

Security


Unlike most UNIX variants, Mac OS X starts out with all native services turned off and all communication ports closed, so the only ports open to allow hackers access are the ones that have been explicitly opened by users — hopefully administrators.

There are also a number of security technologies built into Mac OS X. These include: Kerberos, authentication, SSH, secure remote login — as opposed to the unencrypted Telnet, SSL, web certificates, Wired Equivalency Protocol (WEP), wireless data encryption, and Virtual Private Network (VPN), remote access to the services offered on a local network. A firewall is also built into Mac OS X.

In addition, Apple works closely with CERT and FIRST — two security watchdog organizations — to make sure that newly discovered security holes are patched quickly.