Seminar Origins of Operating Systems

The Microkernel in NeXTSTEP

Gregor Schmidt 2006-06-29

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 1

1 Overview

 Introduction . The road to NeXTSTEP . The NeXT computers  The NeXTSTEP  The Mach Microkernel . Interprocess Communication by example  The steps

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 2

2 Overview

 Introduction  The NeXTSTEP operating system  The Mach Microkernel  The next steps

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 3

3 The Road to NeXTStep

 1986 - NeXT computers, Inc. was founded by and . colleagues from Apple - - - - Dan‘L Lewin - . and - Randy Heffner - Gary H. Moore  1988 - The first computer was presented

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 4

4 The NeXT computers

 based on Motorola 680x0  2 basic models . NeXTcube (1989) . NeXTstation (1990) - 25 MHz resp. 33 MHz - 8 MB RAM (up to 32 MB) - 105 MB SCSI HDD - Floppy Disc Drive - 10Base-T and 10Base-2 - Monochrome Display $ 4.995,-

 All later versions of NeXTSTEP operating systems run on these machines

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 5

5 Overview

 Introduction  The NeXTSTEP operating system  The Mach Microkernel  The next steps

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 6

6 The NeXTStep Operating System Main Features

 Mach Kernel  BSD4.3 user space server  NeXTSTEP

 Display Postscript  Object-oriented application framework  Objective C as standard programming language  Extraordinary OO-development tools  High integration of all native applications

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 7

7 The NeXTSTEP Operating System Demo - By Steve Jobs

 Product Demonstration of NeXTSTEP Release 3.0

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 8

8 Overview

 Introduction  The NeXTSTEP operating system  The Mach Microkernel  The next steps

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 9

9 The Mach Microkernel History

 1985 - 1994 - developed at Carnegie-Mellon university  Microkernel

 Deployed in several systems . NeXTSTEP / OPENSTEP - Rhapsody - Mac OS X . GNU/Hurd . MkLinux . Tru64 (OSF/1)  NeXTSTEP uses Mach 2.5

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 10

10 The Mach Microkernel Microkernel

 Little features - great reliability  Only the main features run in privileged mode . Process management - Scheduling . Synchronization and communication  Device drivers and all other services run as user services

 lots of communication  small interface overhead  little trusted computing base  lots of synchronization

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 11

11 The Mach Microkernel Main Features

 Preemptive Multitasking  Multithreading, Multiprocessing  Memory protection, virtual memory  Interprocess communication via mach messages

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 12

12 The Mach Microkernel Interprocess Communication

 Transparent network support  Typed messages . including type conversion between different languages  Integrated with virtual memory . local messages are not copied . but mapped into receiver‘s address space . Remote messages are send lazily  Port Rights Management . Ownership . Receive . Send  Port names - unique Integer

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 13

13 3

Jeder Port wird durch einen eindeutigen Namen bezeichnet. Diese Namen sind durch ganzzahlige Werte implementiert. Verschiedene Tasks können ihre eigenen, womöglich verschiedenen Namen für denselben Port besitzen. Werden Port-Namen in Nachrichten versandt, so transformiert der Mach-Kern den für den Absender gültigen Namen in einen in der Empfänger-Task gültigen Namen. Dabei wird der zugehörige Port für die Empfänger-Task womöglich erst angelegt. Interessant bleibt jedoch die Frage, wie eine Task jemals von einer anderen Task erfahren kann. Erst dann kann sie ihr ja eine Nachricht senden und mitteilen, unter welchem Port sie selbst erreichbar ist.

3. Verteiltes Rechnen Modelle für verteiltes Rechnen sollen die physische Verteilung der Komponenten einer Anwendung verbergen und die Existenz des Netzwerks verdecken. Kommunizierende Tasks können dann genauso leicht auf verschiedenen Maschinen ausgeführt werden, wie auf einer einzigen. Machs-IPC stellt ein solches Modell dar und unterstützt sogar trans- parente Kommunikation in heterogenen Umgebungen. Anhand eines Klient/Server-Beispiels wollen wir die Möglichkeiten und Werkzeuge die Mach bietet, erläutern. Die beiden Komponenten unserer verteilten Anwendung heißen packets_client und packets_server. Der Klient kann Nachrichten mit The Macheinem Microkernel Integer-Wert an den Server schicken. Er ruft dazu eine Routine send_pa- cket() auf. Der Server druckt für jeden empfangenen Wert eine Notiz aus. Sendet How to manfind sehr Ports viele in Nachrichten NeXTStep hintereinander oder senden viele Klienten auf einmal an einen Server, so kann eine Überflutung von Puffern oder des Netzwerkes autreten. Zum Aufspüren derartiger Fälle ist unsere Anwendung geeignet — wenn man Klient und  Environment ServManagerer noch ein wenig erweitert. . for local use onlyBevor Klient und Server kommunizieren können, stellt sich nun die Frage, wie beide voneinander erfahren. Sie kommunizieren dazu mit einem Namensdienst. Bild 1 zeigt  Network Messagedie Initialisierungsschritte, Server die vor der ersten Klient/Server-Interaktion nötig sind. . enables network-wide communication

 Service Server netname_look_up() 2 netmsgserver

packets_client 3

4 netname_check_in()

send_packet() 1

packets_server

 in Mac OS X: Bootstrap Server Bild 1: Der Mach-Namensdienst

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 14

14 6

senden kann. Mit dem Mach Interface Generator (MIG) existiert jedoch ein leistungs- fähiges Werkzeug, das uns viel von diesem Programmieraufwand abnimmt.

4. Der Mach Interface Generator Ausgehend von einer Spezifikation, packets.defs in unserem Beispiel (der Suffix .defs ist üblich), erzeugt der Mach Interface Generator C-Code für Klient und Server. Auf der Klienten-Seite wird dabei ein procedure call interface zu Mach-Nachrichten generiert, während auf der Server-Seite ein message passing interface zu den C- Funktionen entsteht, die die Server-Funktionalität implementieren. Der Programmierer hat mit dem Erzeugen von Mach-Nachrichten-Strukturen, dem Eintragen von Typ- und Längeninformation und der Zuordnung verschiedener Typen von Nachrichten zu ver- The Mach Microkernelschiedenen Funktionen auf der Server-Seite nichts zu tun. In Bild 4 zeigen wir die von MIG generierten Dateien in ihrer Beziehung zu ‘‘von Hand’’ codierten Pro- Message Sending grammstückthe Easyen. Way

 Mach Interface Generator packets.defs  Corba-like Stub-and-Skeleton-Generator

mig generate generate  Message encoding and

decoding for free packets.h include include  Little RPC-specific code

packets_client.c packetsUser.c

packetsServer.c packets_server_main.c

link link

packets_client packets_server

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Bild 4: GenerierenOrigins von Klientof Operating und SystemsServer -aus The einerMicrokernel MIG Mach Spezifikation15 In Bild 4 bezeichnen Ellipsen jeweils ausführbare Programme. Zentral ist hier /usr/bin/mig, der Mach Interface Generator (MIG). Namen in Kästchen bezeichnen 15 Dateien mit C-Quelltext oder MIG-Spezifikationen. Die in Bild 4 fett gedruckten Dateinamen deuten auf Programmstücke, die der Programmierer zu erstellen hat, der Rest The Mach Microkernel Interprocess Communication by Example

 Calculator example . Server providing calculation facilities . Client using command line interface to receive tasks and queries server for the answer

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 16

16 Overview

 Introduction  The NeXTSTEP operating system  The Mach Microkernel  The next steps

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 17

17 The next steps

 1995 - reorganization of NeXT towards software  NeXT computers, Inc. - NeXT software, Inc.  NeXTSTEP - OPENSTEP  support for different platforms . all NeXT computers . Intel based computers . PA-RISC . Sun SPARC . (IBM PPC) in labs  WebObjects - first application server

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 18

18 The next steps OpenStep and OPENSTEP

 OpenStep is an object oriented API  Designed by NeXT and Sun  OPENSTEP is an implementation  Other for . Windows NT . Solaris . Linux - GNUStep  Main components . Display PostScript . Objective-C Runtime and Compilers . Majority of NeXTSTEP's Objective-C libraries

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 19

19 The next steps

 1996 - take over by Apple, Inc. - 400 Millions US$  OPENSTEP becomes Mac OS X . with a new User Interface - Aqua . but the same underlying system components

. Mach enhanced to XNU (hybrid kernel) within Darwin

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 20

20 References

 BOYKIN, Joseph; KIRSCHEN, David; LANGERMAN, Alan; LoVERSO; Susan: Programming under Mach. Addison-Wesley UNIX and Open System Series, ISBN 0-201-52739-1, Addison-Wesley 1993  GARFINKEL, Simon L.; MAHONEY, Michael K.: NeXTSTEP PROGRAMMING STEP ONE: Object-Oriented Applications. TELOS. The Electronic Library of Science ISBN 0-387-97884-4, Springer-Verlag 1993  POLZE, Andreas: Vereiltes Rechnen unter Mach. unix/mail 2/1995, Carl Hanser Verlag München. Verfügbar im : . - online im Internet  SLABIHOUD, Stephan: NeXT Computer, Inc., 1998-2005, Verfügbar im Internet: . Stand: Juni 2006 - online im Internet

 Special References: . en.wikipedia.org - for lots of information around NeXTStep and Mach . lists.apple.com - for good code example and special information

Betriebssysteme und Middleware / Prof. Andreas Polze Gregor Schmidt Hasso-Plattner-Institut Origins of Operating Systems - The Microkernel Mach 21

21