Operating Systems
Principles & Practice
Volume I: Kernels and Processes
Second Edition
Thomas Anderson
University of Washington
Mike Dahlin
University of Texas and Google
Recursive Books
recursivebooks.com
Operating Systems: Principles and Practice (Second Edition) Volume I:
Kernels and Processes by Thomas Anderson and Michael Dahlin
Copyright ©Thomas Anderson and Michael Dahlin, 2011-2015.
ISBN 978-0-9856735-3-6
Publisher: Recursive Books, Ltd., http://recursivebooks.com/
Cover: Reflection Lake, Mt. Rainier
Cover design: Cameron Neat
Illustrations: Cameron Neat
Copy editors: Sandy Kaplan, Whitney Schmidt
Ebook design: Robin Briggs
Web design: Adam Anderson
SUGGESTIONS, COMMENTS, and ERRORS. We welcome suggestions,
comments and error reports, by email to suggestions@recursivebooks.com
Notice of rights. All rights reserved. No part of this book may be reproduced,
stored in a retrieval system, or transmitted in any form by any means —
electronic, mechanical, photocopying, recording, or otherwise — without the
prior written permission of the publisher. For information on getting
permissions for reprints and excerpts, contact
permissions@recursivebooks.com
Notice of liability. The information in this book is distributed on an “As Is"
basis, without warranty. Neither the authors nor Recursive Books shall have
any liability to any person or entity with respect to any loss or damage caused
or alleged to be caused directly or indirectly by the information or
instructions contained in this book or by the computer software and hardware
products described in it.
Trademarks: Throughout this book trademarked names are used. Rather than
put a trademark symbol in every occurrence of a trademarked name, we state
we are using the names only in an editorial fashion and to the benefit of the
trademark owner with no intention of infringement of the trademark. All
trademarks or service marks are the property of their respective owners.
To Robin, Sandra, Katya, and Adam
Tom Anderson
To Marla, Kelly, and Keith
Mike Dahlin
Contents
Preface
I Kernels and Processes
1 Introduction
1.1 What Is An Operating System?
1.1.1 Resource Sharing: Operating System as Referee
1.1.2 Masking Limitations: Operating System as Illusionist
1.1.3 Providing Common Services: Operating System as Glue
1.1.4 Operating System Design Patterns
1.2 Operating System Evaluation
1.2.1 Reliability and Availability
1.2.2 Security
1.2.3 Portability
1.2.4 Performance
1.2.5 Adoption
1.2.6 Design Tradeoffs
1.3 Operating Systems: Past, Present, and Future
1.3.1 Impact of Technology Trends
1.3.2 Early Operating Systems
1.3.3 Multi-User Operating Systems
1.3.4 Time-Sharing Operating Systems
1.3.5 Modern Operating Systems
1.3.6 Future Operating Systems
Exercises
2 The Kernel Abstraction
2.1 The Process Abstraction
2.2 Dual-Mode Operation
2.2.1 Privileged Instructions
2.2.2 Memory Protection
2.2.3 Timer Interrupts
2.3 Types of Mode Transfer
2.3.1 User to Kernel Mode
2.3.2 Kernel to User Mode
2.4 Implementing Safe Mode Transfer
2.4.1 Interrupt Vector Table
2.4.2 Interrupt Stack
2.4.3 Two Stacks per Process
2.4.4 Interrupt Masking
2.4.5 Hardware Support for Saving and Restoring Registers
2.5 Putting It All Together: x86 Mode Transfer
2.6 Implementing Secure System Calls
2.7 Starting a New Process
2.8 Implementing Upcalls
2.9 Case Study: Booting an Operating System Kernel
2.10 Case Study: Virtual Machines
2.11 Summary and Future Directions
Exercises
3 The Programming Interface
3.1 Process Management
3.1.1 Windows Process Management
3.1.2 UNIX Process Management
3.2 Input/Output
3.3 Case Study: Implementing a Shell
3.4 Case Study: Interprocess Communication
3.4.1 Producer-Consumer Communication
3.4.2 Client-Server Communication
3.5 Operating System Structure
3.5.1 Monolithic Kernels
3.5.2 Microkernel
3.6 Summary and Future Directions
Exercises
II: Concurrency
4. Concurrency and Threads
5. Synchronizing Access to Shared Objects
6. Multi-Object Synchronization
7. Scheduling
III: Memory Management
8. Address Translation
9. Caching and Virtual Memory
10. Advanced Memory Management
IV: Persistent Storage
11. File Systems: Introduction and Overview
12. Storage Devices
13. Files and Directories
14. Reliable Storage
References
Glossary
About the Authors