Home Up Questions?

The Mach Kernel

James L. Peterson

Advanced Workstations Division
11400 Burnet Road
Austin, Texas 78758

March 1992

This paper has been published. It should be cited as

James L. Peterson, ``The MACH Kernel'', Share Europe, Cannes, France, Session 4.7B/U006, (March - April 1992).


The Mach Operating System was developed at Carnegie-Mellon University as a compatible extension of the UNIX 1 operating system providing advanced operating system features, such as threads and support for multi-processors. The Mach kernel provides both shared memory and message-based inter-process communication models to support programs composed of multiple tasks running on multiple processors.

The support for multi-processing combined with the work to keep Mach portable led the Open Software Foundation to use Mach as the basis for its OSF/1 2 operating system. OSF/1 has been ported and demonstrated on a number of hardware platforms, including, at IBM 3, the PS/2 4 personal computer, the ES/9000 5 mainframe, and the RISC System/6000 6 workstation. Still under development by both CMU and OSF 7 is the Mach 3.0 microkernel. Both OSF/1 and the Mach microkernel are being used by IBM for some experimental systems, to investigate their function and performance.

1.0 Background

Operating systems provide an environment in which programs can execute. Most early operating systems were written specifically for a particular computer system or family of systems. Different operating systems provided different environments, and so programs and users could not move easily from one system to another.

In the late 1970s and the 1980s, the UNIX operating system provided a common environment across many different systems, allowing program and user portability. In addition, the UNIX operating system provided a number of simple concepts in a fairly small system, allowing it to be easily understood. The small, simple nature of the UNIX operating system, combined with writing it in a systems programming language, C, encouraged people to port it to many different systems.

The UNIX operating system was originally developed at Bell Labs but its use grew, particularly in University and Research labs. The Defense Advanced Research Projects Agency (DARPA) saw the UNIX operating system as a common platform for its many researchers, providing a common environment to encourage sharing and cooperation in their work. DARPA funded the Computer Science Research Group at the University of California at Berkeley to develop a version of the UNIX operating system for widespread use in computer science research.

But the early UNIX operating system, while providing a good base operating system, lacked many things that were expected in a modern operating system of the time. So it was modified to include these new features. Virtual memory, in the form of demand paging, was added. The file system was rewritten with much more attention given to reliability and performance. Entirely new concepts were created to support networks of computers. The network support, in particular, developed from simple device drivers to the complete TCP/IP protocol and then was generalized to allow even more protocols.

All this additional function greatly increased the usefulness of the environment provided by the UNIX operating system, but it came at a cost. The size of the system increased substantially. In addition to the increase in size was a less quantifiable increase in complexity. The UNIX operating system became a very sophisticated and complex system.

Even with the additional function in the UNIX operating system, it appeared that still more function would be needed. A major problem was support for multiprocessor systems. With the complexity of the existing UNIX systems, adding multiprocessor support would be very difficult and would make the system even more complex and difficult to work with. In addition, the UNIX operating system would still be a uniprocessor system modified to work for a multiprocessor system, not a system designed from the beginning for multiprocessors.

So, in 1985, DARPA agreed to fund the development of a new operating system, Mach, at Carnegie-Mellon University (CMU). Mach was based upon earlier systems at CMU, including Accent, and was to be developed specifically for multiprocessors. In addition, it was designed around a new set of operating system concepts, refined by additional years of research and thought since the design of the UNIX operating system. To maintain a common environment for the existing applications for the UNIX operating system and community, however, it was to be UNIX-compatible.

2.0 Mach Concepts

Mach was designed around a few basic concepts. The hope was to provide general concepts and facilities which were fundamental to operating system functions. Other functions could then be defined or implemented in terms of these basic concepts.

The basic concepts of Mach are suitable for both networks of systems and multiprocessors. Multiple threads within a task can be scheduled on the multiple processors of a multiprocessor. Messages and ports can be used to define communication over a network.

3.0 Mach 2.5

Mach has been implemented and developed to its current widely used version, Mach 2.5. Mach 2.5 provides the basic functions needed by an operating system: memory management, processor scheduling, device support and interprocess communication. In addition to the interface defined by Mach, it also provides a complete UNIX 4.3BSD interface.

Figure 1. Mach 2.5 Operating System Structure; Mach 2.5 includes BSD Unix.

The UNIX 4.3BSD functionality is provided by reusing, almost intact, the actual code from UNIX 4.3BSD. Mach provides a set of basic functions, its kernel services. The UNIX 4.3BSD code was modified to use the Mach kernel services where possible. Mach provides the mechanisms, but the UNIX 4.3BSD code provides the policies. This provides true UNIX 4.3BSD compatibility since Mach 2.5 literally includes UNIX 4.3BSD.

In addition, however, Mach 2.5 has been designed to provide additional features. It has complete multiprocessor support, both in providing scheduling of threads on multiple processors and in allowing multiple processors to execute the Mach kernel at the same time. Data structures which may be modified by multiple processors are locked before update and unlocked after update to prevent simultaneous update by two processors.

Extensive work has been done on the Mach memory management code. Mach allows threads to share memory. Memory sharing can be done in many ways. For instance, when a process forks, the child process is started in an address space which is identical to the address space of the parent. Normally this requires that a copy of the entire address space be created for the child even though the most common action for the child is an exec, which discards the newly copied address space and replaces it with a new program. In Mach, the address space of the child is created by sharing the existing memory objects, copy-on-write. If either the child or the parent tries to modify their shared address space, the page that is being modified is copied (and no longer shared). This provides correct UNIX semantics, but at much lower cost in most cases.

Messages are also tied into the virtual memory system. A large message is sent simply by changing the page tables to map the new memory into the address space of the receiving process, copy-on-write if need be. Thus, it is reasonable to send very large messages from task to task in Mach.

Figure 2. Mach is cleanly split into machine dependent and machine independent code.

Mach virtual memory is provided by demand paging. With careful design of the paging system, it is possible to separate the paging mechanism from the actual getting and putting of pages to the backing store. By using Mach messages for this interface, Mach allows user written external pagers to be used for some memory objects. This allows significant flexibility in memory management on different architectures.

Another important property of the Mach kernel is its separation of the kernel code into clearly defined machine independent and machine dependent portions. This separation speeds porting Mach to additional systems, since the code that must be provided or replaced for a new architecture is easily identified.

The portability of Mach, as well as its multiprocessor design were important factors in its selection as the base for OSF/1, the operating system provided by the Open Software Foundation (OSF). OSF/1 is based on Mach 2.5. The libraries and commands for OSF/1, however, were taken from IBM's AIX 8 operating system.

OSF/1 is beginning to see significant presence. Within IBM, it has been ported to the PS/2 personal computer, the RISC System/6000 workstation, and to the ES/9000 mainframe. The ES/9000 mainframe is a multiprocessor system.

Mach is also the operating system for the NeXT 9 machine.

4.0 Mach 3.0

Development on Mach is continuing at CMU. One of the problems of the UNIX operating system was its size. Since Mach 2.5 includes UNIX 4.3BSD, Mach 2.5 is larger than UNIX 4.3BSD. However, much of the size of Mach 2.5 is in the UNIX 4.3BSD code, not the Mach code itself. This problem is solved in Mach 3.0 by moving the BSD code out of the kernel.

The UNIX 4.3BSD code has been modified to use the kernel services (memory management, processor scheduling, messages, and so on) of the Mach kernel. Mach 3.0 restructures the system so that the UNIX 4.3BSD code runs in user space, as a BSD server. An application, running in user space, makes requests to the BSD server by messages. The Mach 3.0 kernel provides support for messages, virtual memory, processor scheduling, and device I/O, but the BSD server provides the policies and functions which make this into a UNIX operating system.

Figure 3. With Mach 3.0, the BSD Unix code is moved out of the kernel.

One result of moving the BSD code out into a user-level server is that the remaining Mach kernel is much smaller; it is often called a microkernel. Another advantage is that all of the code in the BSD server is now pageable and preemptible, since it is run as just another user task.

A similar approach has been taken by the OSF Research Institute in Grenoble. Starting with the Mach 3.0/BSD server system from CMU, they replaced the BSD server with an OSF/1 server. Care in the interfaces to the Mach kernel (plus OSF/1 being based on Mach 2.5) allows over 90% of the code for OSF/1 to be reused unchanged in the OSF/1 server.

Other servers have also been built on the Mach 3.0 microkernel. CMU has a DOS server, allowing Mach 3.0 on 386 machines to run DOS applications. IBM is experimenting with an OS/2 server. Digital Equipment Corporation has reported work on a VMS 10 server. A System V 11 server is also being considered.

Since the operating system server runs in user space, it is possible to run more than one server at the same time. This allows multiple applications, written for different operating systems, to be run on the same system at the same time. For example, Mach 3.0 has been demonstrated running both UNIX 4.3BSD and DOS programs at the same time. The OSF/1 server was developed in part by using the BSD server to provide services and debugging for the OSF/1 server.

Figure 4. Mach 3.0 can support multiple different operating system servers.

Mach 3.0 is designed to allow another form of multiple servers, servers defined by function. There are several large pieces of the UNIX servers that would seem to be independent of much of the rest of the server. For example, the file system code would seem a good candidate for a separate server. Similarly, the network protocol code can be separated into a server of its own.

Figure 5. Mach 3.0 can support multiple different functional servers.

Defining functional servers allows multiple operating system servers to use the same functional server (for example, the BSD and OSF/1 servers can both use the same file server), and would allow applications to choose servers to match their needs, rather than just what was provided by a particular operating system. It also opens the door to other ways of providing and sharing code and function. The major current Mach research at CMU is on defining an operating system as a collection of cooperating servers.

Multiple functional servers also would seem a good use of multiprocessor capabilities.

Within IBM, we are trying to understand and work with Mach 3.0. Ports are underway to put Mach 3.0 on both the PS/2 personal computer and the RISC System/6000 workstation. Working with CMU and OSF, both the BSD server and the OSF/1 server are being investigated. In addition, research is being done on an OS/2 server. Two major questions here are both the ability of Mach 3.0 to support multiple operating servers (both different operating system servers and separate functional servers) and the performance of these systems for different machine architectures and configurations.


  1. Mike Accetta, Robert Baron, David Golub, Richard Rashid, Avadis Tevanian, and Michael Young. Mach: A New Kernel Foundation for UNIX Development. Proceedings of the Summer 1986 USENIX Conference, (July 1986), pages 93-112.

  2. David Golub, Randall Dean, Alessandro Forin, and Richard Rashid. Unix as an Application Program. Proceedings of the Summer 1990 USENIX Conference, (June 1990).

  3. Abraham Silberschatz, James L. Peterson, and Peter B. Galvin, The Mach Operating System, in Operating System Concepts, Third Edition, Addison-Wesley, 1991, pages 597-629.

  4. Presentation material from the OSF Research Institute Symposium 92 on the Mach Microkernel, Open Systems Foundation Research Institute, February 1992.


1. UNIX is a trademark of Unix System Laboratories, Inc.
2. OSF/1 is a trademark of Open Software Foundation, Inc.
3. IBM is a trademark of IBM Corporation.
4. PS/2 is a trademark of IBM Corporation.
5. ES/9000 is a trademark of IBM Corporation.
6. RISC System/6000 is a trademark of IBM Corporation.
7. OSF is a trademark of Open Software Foundation, Inc.
8. AIX is a trademark of IBM Corporation.
9. NeXT is a trademark of NeXT Computer, Inc.
10. VMS is a trademark of Digital Equipment Corporation.
11. System V is a trademark of American Telephone and Telegraph.
Home   Comments?