Transcript PowerPoint
A Case Study
Michael R. Mahair II
CPSC 550
What is Mach?
An operating system microkernel
Microkernel- minimal operating system kernel that provides only
a basic set of operating system services
Other services provided by user-space programs called servers
Originally developed at Carnegie Mellon University to support
operating system research
Replacement for the kernel in BSD (Unix)
Still the standard by which other microkernel projects are
measured
In use in many commercial operating systems (including Mac
OS X)
History (1)
Developed at CMU between 1981 and 1994
1986: the virtual memory and communication subsystems
were running on the DEC VAX computer family, including
multiprocessor versions of the VAX
1987: first official releases – Release 0 and Release 1
Ended with Mach 3.0
Gained much industry attention in 1989
The Open Software Foundation (OSF) announced that it
would use Mach 2.5 as the basis for its new operating
system, OSF/1
History (2)
In Mach 3.0, compatibility with
BSD was improved
Previous versions included
much of the BSD kernel
3.0 moved the BSD code
outside of the kernel, resulting
in a much smaller microkernel
All Unix specific code runs in
user-mode servers
Running in user-mode servers
allows BSD code to be easily
replaced with another operating
system, or the simultaneous
execution of multiple operatingsystem interfaces on top of the
microkernel
The Mach 3.0 System
Image from appendix of “The Mach System”
History (3)
Mach 4.0 developed at University of Utah after CMU’s project
finished
Since then, Mach and its derivatives have been used in a
number of commercial systems, most notably Mac OS X
Encore's Multimax
NeXT OS
MachTen for the Macintoshes
Omron's Luna
DEC's OSF/1 for the DEC Alpha
IBM's OS/2 for the RS6000 based machines.
NEXTSTEP
OPENSTEP
Goals
From CMU’s “The Mach System” web page:
Providing inter-process communication functionality at the kernel level and
using it as a building block for the rest of the system.
Virtual memory support provided by the kernel and by user level servers.
Kernel level support for light-weight threads.
Support for closely and loosely coupled multi-processors and a variety of
different commercially available workstations.
Micro-kernel architecture limiting the functions supported by the microkernel and enabling multiple user level servers to support various
Application and Programming Interfaces
Maintaining at least one Unix-style API to enable the Mach system to
support all the everyday uses of the project members and other researchers.
Distributing this technology to other researchers and commercial sites to use
as the basis for further research or products.
Definitions (1)
Microkernel
Minimal operating system kernel that provides only a basic set of operating
system services
Task
“An execution environment that provides the basic unit of resource
allocation. It consists of a virtual address space and protected access to
system resources via ports, and it may contain one or more threads.”
(Silberschatz)
Thread
“The basic unit of execution and must run in the context of a task (which
provides the address space). All threads within a task share the tasks’
resources (ports, memory, and so on). There is no notion of a process in
Mach. Rather, a traditional process would be implemented as a task with a
single thread of control.” (Silberschatz)
Definitions (2)
Port
“The basic object-reference mechanism in Mach and is implemented as a
kernel-protected communication channel. Communication is accomplished
by sending messages to ports; messages are queued at the destination port if
no thread is immediately ready to receive them. Ports are protected by
kernel-managed capabilities, or port rights; a task must have a port right to
send a message to a port. The programmer invokes an operation on an object
by sending a message to a port associated with that object. The object being
represented by a port receives the messages.” (Silberschatz)
Port set
“A group of ports sharing a common message queue. A thread can receive
messages for a port set and thus service multiple ports. Each received
message identifies the individual port (within the set) from which it was
received; the receiver can use this to identify the object referred to by the
message.” (Silberschatz)
Definitions (3)
Message
“The basic method of communication between threads in Mach. It is a
typed collection of data objects; for each object, itmay contain the actual
data or a pointer to out-of-line data. Port rights are passed in messages;
this is the only way to move them among tasks. (Passing a port right in
shared memory does not work, because the Mach kernel will not permit
the new task to use a right obtained in this manner.)” (Silberschatz)
Memory Object
“A source of memory; tasks can access it by mapping portions of an
object (or the entire object) into their address spaces. The object can be
managed by a user-mode external memory manager. One example is a
file managed by a file server; however, a memory object can be any
object for which memory-mapped access makes sense. A mapped buffer
implementation of a UNIX pipe is one example.” (Silberschatz)
Features (1)
Microkernel Architecture
Adding a new service does not require modifying the kernel
More operations are done in user mode rather than in the kernel,
providing more security
Simpler kernel design generally produces more reliable system
General enough to support multiple operating system interfaces
Support for diverse architectures, including multiprocessor
with different memory access levels:
Uniform Memory Access (UMA)
Non-Uniform Memory Access (NUMA)
No Remote Memory Access (NORMA)
Features (2)
Distributed operations
Network transparency to clients
Object-oriented organization
Functions with various inter-computer network speeds
Wide area networks
Local area networks
Tightly-coupled multiprocessors
Integrated memory management and inter-process
communication
Efficient communication of large amounts of data
Communication-based memory management
Structure (1) - Overview
Mach Basic Structure
Image from appendix of “The Mach System”
Structure (2)
Process Management
Mach handles tasks and threads. One task can store multiple threads.
Tasks/Threads are either Running or Suspended.
Mach provides minimal yet sufficient functionality in the kernel for handling tasks
and threads.
C Threads package
A package (with OTB Mach) to do more advanced thread handling
CPU Scheduler
Only threads scheduled, not tasks
Threads assigned priority between 0 and 127 based on recent CPU usage
Threads placed in one of 32 queues based on priority
Exception Handling
A raise RPC messages is sent to the handler by the thread
Thread calls a routine to wait until the exception is handled
Handler receives information about the exception, including the thread and the task
Based on the type of exception, the handler either resumes or terminates the thread
Structure (3)
Interprocess Communication
Ports
The kernel creates several ports for each task that is created
Ports can be collected in to Port Sets, which is useful if a thread services
requests coming in on multiple ports (multiple objects)
Messages
Consists of fixed-length header and variable number of typed data objects
Network Message Server (NetMsgServer)
Handles IPC across different machines on the distributed OS
Transparent to the user
Synchronization
Port is used as a synchronization variable. Threads wishing to use the port
send a “receive” command. The port waits if there is no incoming message.
To return the resource after use, a thread simply sends a message to the port.
Structure (4)
Memory Management
User Level Memory Managers
Mach allows user level memory managers by allowing memory to be
created and serviced by non-kernel tasks
Memory can be paged by user level memory managers
When an object is destroyed, it is up to the memory manager to write
back any changed pages to secondary storage
Shared Memory
No shared memory necessary within a task- all threads share the task’s
memory
Shared memory management is still provided for other Unix constructs,
such as the fork system call
Mach does not solve the problem directly, but provides the user with the
ability to manage memory across tasks and across machines
Usage
Because Mach 3.0 uses a microkernel, only the basic
features of the kernel are available
Full functionality is provided by using emulation libraries
that reside outside of the kernel
Emulation Libraries are sets of routines that live in a
read-only part of a program’s address space
More complex operating systems (such as BSD) can be
created by using multiple emulation libraries in
combination one or more servers
Run-time libraries, such as the C Threads package, can
also be created to provide more functionality.
Applications
Encore's Multimax
NeXT OS
MachTen for the Macintoshes
Omron's Luna
DEC's OSF/1 for the DEC Alpha
IBM's OS/2 for the RS6000 based machines.
NEXTSTEP
OPENSTEP
Mac OS X (using the XNU kernel)
Significance
One of the earliest examples of a microkernel
Used in many commercial operating systems
Some performance problems cause Mach not to be the
best choice compared to other distributed operating
systems
Some of the features implemented in the kernel that caused
performance problems were not always necessary
Helped lead to second generation microkernels (such as
the L4 kernel), which improved many of the performance
problems by moving even more functionality into the
user-space
Summary
The Mach System, especially Mach 3.0, is an excellent
example of one of the earliest microkernel systems.
Although it is not heavily used because of some
performance problems, it helped lead the way to many of
the higher performance second generation microkernels.
References
Coulouris, George, Jean Dollimore & Tim Kindberg. Distributed Systems: Concepts
and Design. 1994. 2nd ed. p 594-597. March 3, 2007.
<http://www.cdk3.net/oss/Ed2/Comparison.pdf>
Härtig, Hermann, Michael Hohmuth, Jochen Liedtke, Sebastian Schönberg, and
Jean Wolter. The Performance of µ-Kernel-Based Systems. 1997 by The
Association for Computing Machinery, Inc. March 3, 2007. <http://os.inf.tudresden.de/pubs/sosp97/>
Silberschatz, Avi, Peter Baer Galvin and Greg Gagne. Operating System Concepts
(appendix only- “The Mach System”). 7th ed. March 3, 2007
http://www.di.unipi.it/~scordino/sisop/mach.pdf
The Mach Project Home Page. Feb 21, 1997. Carnegie Mellon University. March
3, 2007 <http://www.cs.cmu.edu/afs/cs/project/mach/public/www/mach.html>
“The Mach System.” Feb 4, 2000. March 3, 2007.
<http://library.nocrew.org/lib/os/Mach.txt>
“The Mach 4 Project.” Nov 3 1995. March 3, 2007.
<http://www.cs.utah.edu/flux/mach4/html/Mach4-proj.html>