Computer Science & Engineering
Operating System Design
The Xinu Approach
Second Edition
With Intel and ARM Examples
Widely lauded for avoiding the typical black box approach found in other operating system textbooks, the first
edition of this bestselling book taught readers how an operating system works and explained how to build it from
the ground up.
Continuing to follow a logical pattern for system design, Operating System Design: The Xinu Approach, Sec-
ond Edition removes the mystery from operating system design and consolidates the body of material into a sys-
tematic discipline. It presents a hierarchical design paradigm that organizes major operating system components
in an orderly, understandable manner.
The book guides readers through the construction of a conventional process-based operating system using prac-
tical, straightforward primitives. It gives the implementation details of one set of primitives, usually the most popu-
lar set. Once readers understand how primitives can be implemented on conventional hardware, they can then
easily implement alternative versions.
The text begins with a bare machine and proceeds step-by-step through the design and implementation of the
Xinu operating system. The Xinu code runs on many hardware platforms. This second edition has been completely
rewritten to contrast operating systems for RISC and CISC processors. Encouraging hands-on experimentation,
the book provides updated code throughout and examples for two low-cost experimenter boards: BeagleBone
Black from ARM and Galileo from Intel.
Features
• Covers topics in the order a designer follows when building a system
• Uses inexpensive embedded platforms from ARM and Intel
• Describes the main components in the design hierarchy
• Presents example software that illustrates the functions provided by each hierarchy level
• Gives readers the foundation to implement alternative versions of primitives
•
• Offers updated code and other information on the author’s website
Includes many practical examples and exercises that facilitate hands-on learning with the code
• Access online or download to your smartphone, tablet or PC/Mac
• Search the full text of this and other titles you own
• Make and share notes and highlights
• Copy and paste text and figures for use in your own documents
• Customize your view by changing font size and layout
K25117
w w w . c r c p r e s s . c o m
WITH VITALSOURCE®
EBOOK
Operating System Design
The Xinu Approach
Second Edition
S
e
c
o
n
d
E
d
i
t
i
o
n
O
p
e
r
a
t
i
n
g
S
y
s
t
e
m
D
e
s
i
g
n
C
o
m
e
r
Douglas Comer
K25117_cover.indd 1
1/6/15 10:33 AM
Operating System Design
The Xinu Approach
Second Edition
Operating System Design
The Xinu Approach
Second Edition
Douglas Comer
UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company, Ltd. Linux is a registered trade-
mark of Linus Torvalds. In the United States, Linux is a trademark registered to Linus Torvalds. Microsoft Windows is a trademark of Microsoft Cor-
poration. Microsoft is a registered trademark of Microsoft Corporation. Solaris is a trademark of Sun Microsystems, Incorporated. MIPS is a registered
trademark of MIPS Technologies, Inc. IBM is a registered trademark of International Business Machines. Mac is a trademark of Apple, Inc. Intel is a
registered trademark of Intel Corporation. Galileo is a registered trademark of Intel Corporation. mini-PCI Express is a trademark of Intel Corporation.
ARM is a registered trademark of ARM Limited. Other trademarks are the property of their respective owners.
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
© 2015 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business
No claim to original U.S. Government works
Version Date: 20141204
International Standard Book Number-13: 978-1-4987-1244-6 (eBook - PDF)
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and
information, but the author and publisher cannot assume responsibility for the validity of all materials or the consequences of their use. The authors and
publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission
to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any
future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic,
mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or
retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.copyright.com/) or contact
the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides
licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment
has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without
intent to infringe.
Visit the Taylor & Francis Web site at
http://www.taylorandfrancis.com
and the CRC Press Web site at
http://www.crcpress.com
To my wife, Chris, and our children, Sharon and Scott
Contents
Preface
About the Author
Chapter 1
Introduction And Overview
xix
xxiii
3
Approach Used In The Text 5
A Hierarchical Design 5
The Xinu Operating System 7
1.1 Operating Systems 3
1.2
1.3
1.4
1.5 What An Operating System Is Not 8
1.6
1.7
1.8
1.9
An Operating System Viewed From The Outside 9
Remainder Of The Text 10
Perspective 11
Summary 11
Chapter 2 Concurrent Execution And Operating System Services
15
Concurrent Processing Concepts And Terminology 17
Introduction 15
Programming Models For Multiple Activities 16
2.1
2.2
2.3 Operating System Services 17
2.4
2.5 Distinction Between Sequential And Concurrent Programs 19
2.6 Multiple Processes Sharing A Single Piece Of Code 21
2.7
2.8
2.9
2.10 Type Names Used In Xinu 30
2.11 Operating System Debugging With Kputc And Kprintf 31
2.12 Perspective 32
2.13 Summary 32
Process Exit And Process Termination 23
Shared Memory, Race Conditions, And Synchronization 24
Semaphores And Mutual Exclusion 28