22C:116, Lecture 39, Spring 1997

Douglas W. Jones
University of Iowa Department of Computer Science

  1. Mach

    Mach was designed at Carnegie Mellon University with the specific goal of producing a distributed foundation on which UNIX systems could be implemented. The goal of providing absolute compatability with UNIX forced some compromizes in the design of this system, but nonetheless, it incorporates some useful ideas.

    Mach is based on a "microkernel", a term that is perhaps a misnomer. As originally proposed, kernels were supposed to be small, in the way that Mach is. The developers of UNIX, however, took over this term and applied it to a fairly large lump -- the UNIX kernel, forcing more recent developers to emphasize that their kernels were, quite properly, small.

    The Mach kernel provides process, thread, memory object, communications port and message management. As with Amoeba and other modern kernel-based systems, it does not include file systems or other high-level abstractions.

  2. Mach Processes

    Each Mach process is made up of a virtual address space and a collection of threads. Processes are passive! The kernel maintains, on behalf of each process, 4 communications ports. Each process has an exception port; whenever a thread in the process raises an exception, for example, by divide by zero, illegal memory reference, or similar problems, the kernel sends a message to the exception port. This message identifies the cause of the exception in detail.

    Messages sent to a process's process port are interpreted by the kernel. All kernel operations on processes that may be carried out by other processes are implemented by messages to the process port instead of by kernel calls. As such, no kernel calls take process ID's as parameters; instead, operations that might take that form are formulated as messages to the process port of the process being manipulated. Process termination, suspension, resumption, priority etc all are handled this way.

    The bootstrap port is used to start a process. The initial thread of the process typically begins by reading from the bootstrap port; when a process is started, the first thing its creator does is send a message to that process's bootstrap port containing the information that process needs in order to run. Typically, this message will include the ports that make up its standard environment and the parameters with which it was created.

  3. Memory

    Mach has a paged model of memory, with the virtual address space of a process divided up into regions, where regions are separated by undefined areas of the address space, and regions are divided up into pages. The Mach kernel does not handle page-faults!

    Instead, when a thread attempts to reference a memory location that is not currently addressable, a message is sent by the kernel to the thread'd process's exception port. The message contains the information necessary for the fault handler -- a thread of some process -- to handle the fault and then restart the thread that caused the fault.

    Note that this implies that all threads of a process will have the same fault handler!

  4. Threads

    Mach threads are lightweight, but implemented by the kernel.

  5. Ports

    Mach ports are not, as in DEMOS or even Amoeba, attributes of a process. Instead, ports are first class objects.

    Mach processes have capability lists, where the capability lists indicate what ports the process may reference!