Transcript Mach

The Mach System
"Operating Systems Concepts, Sixth Edition"
by Abraham Silberschatz, Peter Baer Galvin, and Greg Gagne
Presented by Abdelhalim Ragab
Portland State University
CS533 Concepts of Operating Systems
Portland State University
-
CS533 Concepts of Operating Systems
Microkernel vs. Monolithic Systems
Source: http://en.wikipedia.org/wiki/File:OS-structure.svg
Portland State University
Mach History

CMU Accent operating system




No ability to execute UNIX applications
Single Hardware architecture
BSD Unix system + Accent concepts
Mach
OpenStep
XNU
GNU Hurd
OSF/1
Darwin
Mac OS X
-
CS533 Concepts of Operating Systems
Portland State University
-
CS533 Concepts of Operating Systems
Design Principles




Maintain BSD Compatibility
Simple programmer
interface
Easy portability
Extensive library of
utilities/applications
Combine utilities via pipes






PLUS
Diverse architectures.
Varying network speed
Simple kernel
Distributed operation
Integrated memory
management and IPC
Heterogeneous systems
Portland State University
-
CS533 Concepts of Operating Systems
System Components
message
text region
threads
port
task






Task
Thread
Port
Port set
Message
Memory object
port set
data region
secondary
storage
memory
object
Portland State University
-
CS533 Concepts of Operating Systems
Memory Management and IPC

Memory Management using IPC:




Memory object represented by port(s)
IPC messages are sent to those ports to request operation on
the object
Memory objects can be remote  kernel caches the contents
IPC using memory-management techniques:


Pass message by moving pointers to shared memory objects
Virtual-memory remapping to transfer large contents
(virtual copy or copy-on-write)
Portland State University
-
CS533 Concepts of Operating Systems
Process Management
Basic Structure


Tasks/Threads
Synchronization primitives:

Mach IPC:



Processes exchanging messages at rendezvous points
Wait/signal associated with semaphores can be implemented using
IPC
Thread-level synchronization using thread start/stop calls
Portland State University
-
CS533 Concepts of Operating Systems
Process Management
C Thread package



User-level thread library built on top of Mach primitives
Influenced POSIX P Threads standard
Thread-control:





Create/Destroy a thread
Wait for a specific thread to terminate then continue the calling
thread
Yield
Mutual exclusion using spinlocks
Condition Variables (wait, signal)
Portland State University
-
CS533 Concepts of Operating Systems
Process Management
CPU Scheduler


Only threads are scheduled
Dynamic thread priority number (0 – 127)



32 global run queues + per processor local queues (ex.
driver thread)
No Central dispatcher



based on the exponential average of its CPU usage.
Processors consult run queues to select next thread
List of idle processors
Thread time quantum varies inversely with total number
of threads, but constant over the entire system
Portland State University
-
CS533 Concepts of Operating Systems
Process Management
Exception Handling


Implemented via RPC messages
Exception handling granularities:



Per thread (for error handling)
Per task (for debuggers)
Emulate BSD style signals


Supports execution of BSD programs
Not suitable for multi-threaded environment
Portland State University
-
CS533 Concepts of Operating Systems
Interprocess Communication
Ports + messages



Allow location independence + communication security
Sender/Receiver must have rights (port name + send
or receive capability)
Ports:


Protected bounded queue in the kernel
System Calls:





Allocate new port in task, give the task all access rights
Deallocate task’s access rights to a port
Get port status
Create backup port
Port sets
Portland State University
-
CS533 Concepts of Operating Systems
Interprocess Communication
Ports + messages

Messages:





Header + typed data objects
Header: destination port name, reply port name, message length
In-line data: simple types, port rights
Out-of-line data: pointers
 Via virtual-memory management
 Copy-on-write
Sparse virtual memory
Portland State University
-
CS533 Concepts of Operating Systems
Interprocess Communication
Ports + messages

NetMsgServer:






user-level capability-based networking daemon
used when receiver port is not on the kernel’s computer
Forward messages between hosts
Provides primitive network-wide name service
Mach 3.0 NORMA IPC
Syncronization using IPC:




Used in threads in the same task
Port used as synchronization variable
Receive message  wait
Send message  signal
Portland State University
-
CS533 Concepts of Operating Systems
Memory Management

Memory Object




Standard system calls for virtual memory functionality
User-level Memory Managers:




Used to manage secondary storage (files, pipes, …), or data
mapped into virtual memory
Backed by user-level memory managers
Memory can be paged by user-written memory managers
No assumption are made by Mach about memory objects
contents
Kernel calls to support external memory manager
Mach default memory manager
Portland State University
-
CS533 Concepts of Operating Systems
Memory Management
Shared memory

Shared memory provides reduced complexity and
enhanced performance



Fast IPC
Reduced overhead in file management
Mach provides facilities to maintain memory consistency
on different machines
Portland State University
-
CS533 Concepts of Operating Systems
Programmer Interface

System-call level



C Threads package



Emulation libraries and servers
Upcalls made to libraries in task address space, or server
C language interface to Mach threads primitives
Not suitable for NORMA systems
Interface/Stub generator (MIG) for RPC calls
Portland State University
-
Mach Microkernel
summary



Simple kernel abstractions
Focus on communication facilities
System Calls:




IPC
Task/Thread/Port
Virtual memory
Mach 3 NORMA IPC
CS533 Concepts of Operating Systems
Portland State University
-
CS533 Concepts of Operating Systems
Mach Microkernel
summary

User level

servers





Memory Managers
NetMsgServer
NetMemServer
OS Servers/Emulation libraries
C Threads user-level thread management package
Portland State University
Questions
-
CS533 Concepts of Operating Systems
Portland State University
-
CS533 Concepts of Operating Systems
Reality

Microkernel vs. Monolithic Systems:
Linus vs. Tanenbaum famous debate (1992):
http://www.dina.kvl.dk/~abraham/Linus_vs_Tanenbaum.html
http://oreilly.com/catalog/opensources/book/appa.html
http://groups.google.com/group/comp.os.minix/browse_thread/thread/c25870d7a41696d2

Again in 2006

L3 Microkernel
L4 microkernel family (L4, L4Ka::Hazelnut, Fiasco, … )
Mac OS X: Although Mac OS X must credit BSD for most of the underlying levels of
the operating system, Mac OS X also owes a major debt to Mach. The kernel is
heavily influenced in its design philosophy by Carnegie Mellon's Mach project[17].
The kernel is not a pure micro-kernel implementation, since the address space is
shared with the BSD portion of the kernel and the I/O Kit.


http://www.cs.vu.nl/~ast/reliable-os/
http://en.wikipedia.org/wiki/Tanenbaum-Torvalds_debate
http://developer.apple.com/technotes/tn2002/tn2071.html
Portland State University
-
CS533 Concepts of Operating Systems
Reality(2)
Are Microkernels for Real

QNX, Integrity, PikeOS, Symbian, L4Linux, Singularity, K42, Mac OS X, HURD, Coyotos

QNX is widely used in real commercial systems. Cisco's top-of-the-line router uses it, for example,
and I can assure you, Cisco cares a **LOT** about performance.
One of the leading operating systems in the military and aerospace markets, where reliability is
absolutely critical is Green Hills' Integrity, another microkernel.
PikeOS is another microkernel-based real-time system widely used in defense, aerospace,
automotive, and industrial applications.
Symbian is yet another popular microkernel, primarily used in cell phones. It is not a pure
microkernel, however, but something of a hybrid, with drivers in the kernel, but the file system,




networking, and telephony in user space.
L4Linux runs all of Linux in user space on top of the L4 microkernel with a performance loss of only a couple of
percent.
IBM K42
HURD
Microsoft Singularity
Mac OSX and Darwin on L4

Source: http://www.cs.vu.nl/~ast/reliable-os/



