Docsity

Operating System, Internals and design principles 6th, Lecture notes of Operating Systems

Partial preview of the text

Download Operating System, Internals and design principles 6th and more Lecture notes Operating Systems in PDF only on Docsity!

OPERATING SYSTEMS

INTERNALS AND DESIGN

PRINCIPLES

SIXTH EDITION

William Stallings

Upper Saddle River, New Jersey 07458

As always,

for my loving and brilliant wife A.

and her constant companion Geoffroi

WEB S ITE FOR OPERATING SYSTEMS: INTERNALS

AND DESIGN P RINCIPLES, S IXTH EDITION

The Web site at WilliamStallings.com/OS/OS6e.html provides support for instructors and students using the book. It includes the following elements.

Course Support Materials The course support materials include

  • Copies of figures from the book in PDF format.
  • Copies of tables from the book in PDF format.
  • A set of PowerPoint slides for use as lecture aids.
  • Lecture notes in HTML that can serve as a useful study aid.
  • Computer Science Student Resource Site: contains a number of links and docu- ments that students may find useful in their ongoing computer science education. The site includes a review of basic, relevant mathematics; advice on research, writ- ing, and doing homework problems; links to computer science research resources, such as report repositories and bibliographies; and other useful links.
  • An errata sheet for the book, updated at most monthly. Supplemental Documents The supplemental documents include
  • A set of supplemental homework problems with solutions. Students can en- hance their understanding of the material by working out the solutions to these problems and then checking their answers.
  • Tutorial documents on C, including C for Java programmers.
  • Two online chapters: networking and distributed process management
  • Six online appendices that expand on the treatment in the book. Topics in- clude complexity of algorithms, Internet standards, and Sockets
  • A PDF copy of all the algorithms in the book in an easy-to-read Pascal-like pseudocode.
  • All of the Windows, UNIX, and Linux material from the book reproduced in three PDF documents for easy reference. OS Courses The Web site includes links to Web sites for courses taught using the book. These sites can provide useful ideas about scheduling and topic ordering, as well as a num- ber of useful handouts and other materials. Useful Web Sites The Web site includes links to relevant Web sites. The links cover a broad spectrum of topics and will enable students to explore timely issues in greater depth. Internet Mailing List An Internet mailing list is maintained so that instructors using this book can ex- change information, suggestions, and questions with each other and the author. Sub- scription information is provided at the book’s Web site. Operating System Projects The Web site includes links to the Nachos and BACI web sites. These are two software packages that serve as frameworks for project implementation. Each site includes down- loadable software and background information. See Appendix C for more information.

T

  • Chapter 0 Reader’s Guide Preface xiii
    • 0.1 Outline of the Book
    • 0.2 A Roadmap for Readers and Instructors
    • 0.3 Internet and Web Resources
  • PART ONE BACKGROUND
  • Chapter 1 Computer System Overview
    • 1.1 Basic Elements
    • 1.2 Processor Registers
    • 1.3 Instruction Execution
    • 1.4 Interrupts
    • 1.5 The Memory Hierarchy
    • 1.6 Cache Memory
    • 1.7 I/O Communication Techniques
    • 1.8 Recommended Reading and Web Sites
    • 1.9 Key Terms, Review Questions, and Problems
      • Appendix 1A Performance Characteristics of Two-Level Memory
      • Appendix 1B Procedure Control
  • Chapter 2 Operating System Overview
    • 2.1 Operating System Objectives and Functions
    • 2.2 The Evolution of Operating Systems
    • 2.3 Major Achievements
    • 2.4 Developments Leading to Modern Operating Systems
    • 2.5 Microsoft Windows Overview
    • 2.6 Traditional UNIX Systems
    • 2.7 Modern UNIX Systems
    • 2.8 Linux
    • 2.9 Recommended Reading and Web Sites
    • 2.10 Key Terms, Review Questions, and Problems
  • PART TWO PROCESSES
  • Chapter 3 Process Description and Control
    • 3.1 What is a Process?
    • 3.2 Process States
    • 3.3 Process Description
    • 3.4 Process Control
    • 3.5 Execution of the Operating System
    • 3.6 Security Issues
    • 3.7 UNIX SVR4 Process Management
    • 3.8 Summary vi CONTENTS
    • 3.9 Recommended Reading
    • 3.10 Key Terms, Review Questions, and Problems
      • Programming Project One Developing a Shell
  • Chapter 4 Threads, SMP, and Microkernels
    • 4.1 Processes and Threads
    • 4.2 Symmetric Multiprocessing (SMP)
    • 4.3 Microkernels
    • 4.4 Windows Vista Thread and SMP Management
    • 4.5 Solaris Thread and SMP Management
    • 4.6 Linux Process and Thread Management
    • 4.7 Summary
    • 4.8 Recommended Reading
    • 4.9 Key Terms, Review Questions, and Problems
  • Chapter 5 Concurrency: Mutual Exclusion and Synchronization
    • 5.1 Principles of Concurrency
    • 5.2 Mutual Exclusion: Hardware Support
    • 5.3 Semaphores
    • 5.4 Monitors
    • 5.5 Message Passing
    • 5.6 Readers/Writers Problem
    • 5.7 Summary
    • 5.8 Recommended Reading
    • 5.9 Key Terms, Review Questions, and Problems
  • Chapter 6 Concurrency: Deadlock and Starvation
    • 6.1 Principles of Deadlock
    • 6.2 Deadlock Prevention
    • 6.3 Deadlock Avoidance
    • 6.4 Deadlock Detection
    • 6.5 An Integrated Deadlock Strategy
    • 6.6 Dining Philosophers Problem
    • 6.7 UNIX Concurrency Mechanisms
    • 6.8 Linux Kernel Concurrency Mechanisms
    • 6.9 Solaris Thread Synchronization Primitives
    • 6.10 Windows Vista Concurrency Mechanisms
    • 6.11 Summary
    • 6.12 Recommended Reading
    • 6.13 Key Terms, Review Questions, and Problems
  • PART THREE MEMORY
  • Chapter 7 Memory Management
    • 7.1 Memory Management Requirements
    • 7.2 Memory Partitioning
    • 7.3 Paging
    • 7.4 Segmentation
      • 7.5 Security Issues CONTENTS vii
      • 7.6 Summary
      • 7.7 Recommended Reading
      • 7.8 Key Terms, Review Questions, and Problems
        • Appendix 7A Loading and Linking
  • Chapter 8 Virtual Memory - 8.1 Hardware and Control Structures - 8.2 Operating System Software - 8.3 UNIX and Solaris Memory Management - 8.4 Linux Memory Management - 8.5 Windows Vista Memory Management - 8.6 Summary - 8.7 Recommended Reading and Web Sites - 8.8 Key Terms, Review Questions, and Problems - Appendix 8A Hash Tables
  • PART FOUR SCHEDULING
  • Chapter 9 Uniprocessor Scheduling - 9.1 Types of Scheduling - 9.2 Scheduling Algorithms - 9.3 Traditional UNIX Scheduling - 9.4 Summary - 9.5 Recommended Reading - 9.6 Key Terms, Review Questions, and Problems - Appendix 9A Response Time - Appendix 9B Queuing Systems - Programming Project TwoThe HOST Dispatcher Shell
  • Chapter 10 Multiprocessor and Real-Time Scheduling
    • 10.1 Multiprocessor Scheduling
    • 10.2 Real-Time Scheduling
    • 10.3 Linux Scheduling
    • 10.4 UNIX FreeBSD Scheduling
    • 10.5 Windows Vista Scheduling
    • 10.6 Summary
    • 10.7 Recommended Reading
    • 10.8 Key Terms, Review Questions, and Problems
  • PART FIVE INPUT/OUTPUT AND FILES
  • Chapter 11 I/O Management and Disk Scheduling
    • 11.1 I/O Devices
    • 11.2 Organization of the I/O Function
    • 11.3 Operating System Design Issues
    • 11.4 I/O Buffering
    • 11.5 Disk Scheduling
    • 11.6 RAID
    • 11.7 Disk Cache viii CONTENTS
    • 11.8 UNIX FreeBSD I/O
    • 11.9 Linux I/O
    • 11.10 Windows Vista I/O
    • 11.11 Summary
    • 11.12 Recommended Reading
    • 11.13 Key Terms, Review Questions, and Problems
      • Appendix 11A Disk Storage Devices
  • Chapter 12 File Management
    • 12.1 Overview
    • 12.2 File Organization and Access
    • 12.3 File Directories
    • 12.4 File Sharing
    • 12.5 Record Blocking
    • 12.6 Secondary Storage Management
    • 12.7 File System Security
    • 12.8 UNIX File Management
    • 12.9 Linux File Management
    • 12.10 Windows Vista File System
    • 12.11 Summary
    • 12.12 Recommended Reading
    • 12.13 Key Terms, Review Questions, and Problems
  • PART SIX EMBEDDED SYSTEMS
  • Chapter 13 Embedded Operating Systems
    • 13.1 Embedded Systems
    • 13.2 Characteristics of Embedded Operating Systems
    • 13.3 eCOS
    • 13.4 TinyOS
    • 13.5 Recommended Reading and Web Sites
    • 13.6 Key Terms, Review Questions, and Problems
  • PART SEVEN SECURITY
  • Chapter 14 Computer Security Threats
    • 14.1 Computer Security Concepts
    • 14.2 Threats,Attacks, and Assets
    • 14.3 Intruders
    • 14.4 Malicious Software Overview
    • 14.5 Viruses,Worms, and Bots
    • 14.6 Rootkits
    • 14.7 Recommended Readings and Web Sites
    • 14.8 Key Terms, Review Questions, and Problems
  • Chapter 15 Computer Security Techniques CONTENTS ix
    • 15.1 Authentication
    • 15.2 Access Control
    • 15.3 Intrusion Detection
    • 15.4 Malware Defense
    • 15.5 Dealing with Buffer Overflow Attacks
    • 15.6 Windows Vista Security
    • 15.7 Recommended Readings and Web Sites
    • 15.8 Key Terms, Review Questions, and Problems
  • PART EIGHT DISTRIBUTED SYSTEMS
  • Chapter 16 Distributed Processing, Client/Server, and Clusters
    • 16.1 Client/Server Computing
    • 16.2 Distributed Message Passing
    • 16.3 Remote Procedure Calls
    • 16.4 Clusters
    • 16.5 Windows Vista Cluster Server
    • 16.6 Sun Cluster
    • 16.7 Beowulf and Linux Clusters
    • 16.8 Summary
    • 16.9 Recommended Reading
    • 16.10 Key Terms, Review Questions, and Problems
  • Appendix A Topics in Concurrency APPENDICES - A.1 Mutual Exclusion: Software Approaches - A.2 Race Conditions and Semaphores - A.3 A Barbershop Problem - A.4 Problems
  • Appendix B Object-Oriented Design - B.1 Motivation - B.2 Object-Oriented Concepts - B.3 Benefits of Object-Oriented Design - B.4 CORBA - B.5 Recommended Reading and Web Site
  • Appendix C Programming and Operating System Projects - C.1 Animations and Animation Projects - C.2 Simulations - C.3 Programming Projects - C.4 Research Projects - C.5 Reading/Report Assignments

x CONTENTS

C.6 Writing Assignments 782 C.7 Documentation Projects 783 C.8 BACI and Nachos 783

ONLINE CHAPTERS AND APPENDICES

Chapter 17 Networking

17.1 The Need for a Protocol Architecture 17.2 The TCP/IP Protocol Architecture 17.3 Sockets 17.4 Linux Networking 17.5 Summary 17.6 Recommended Reading and Web Sites 17.7 Key Terms, Review Questions, and Problems Appendix 17A The Trivial File Transfer Protocol

Chapter 18 Distributed Process Management

18.1 Process Migration 18.2 Distributed Global States 18.3 Distributed Mutual Exclusion 18.4 Distributed Deadlock 18.5 Summary 18.6 Recommended Reading 18.7 Key Terms, Review Questions, and Problems

Appendix D The Complexity of Algorithms

Appendix E Standards Organizations

E.1 The Importance of Standards E.2 Standards and Regulation E.3 Standards-Setting Organizations

Appendix F Cryptographic Algorithms

F.1 Symmetric Encryption F.2 Public-Key Cryptography F.3 Secure Hash Functions

Appendix G The International Reference Alphabet

Appendix H BACI: The Ben-Ari Concurrent Programming System

H.1 Introduction H.2 BACI H.3 Examples of BACI Programs H.4 BACI Projects H.5 Enhancements to the BACK System

Appendix I Sockets: A Programmer’s Introduction

I.1 Versions of Sockets I.2 Sockets, Socket Descriptors, Ports, and Connections

This page intentionally left blank

PREFACE

OBJECTIVES

This book is about the concepts, structure, and mechanisms of operating systems. Its purpose is to present, as clearly and completely as possible, the nature and characteristics of modern- day operating systems. This task is challenging for several reasons. First, there is a tremendous range and vari- ety of computer systems for which operating systems are designed. These include single-user workstations and personal computers, medium-sized shared systems, large mainframe and supercomputers, and specialized machines such as real-time systems. The variety is not just in the capacity and speed of machines, but in applications and system support requirements. Second, the rapid pace of change that has always characterized computer systems continues with no letup. A number of key areas in operating system design are of recent origin, and re- search into these and other new areas continues. In spite of this variety and pace of change, certain fundamental concepts apply consis- tently throughout. To be sure, the application of these concepts depends on the current state of technology and the particular application requirements. The intent of this book is to pro- vide a thorough discussion of the fundamentals of operating system design and to relate these to contemporary design issues and to current directions in the development of operat- ing systems.

EXAMPLE SYSTEMS

This text is intended to acquaint the reader with the design principles and implementation is- sues of contemporary operating systems. Accordingly, a purely conceptual or theoretical treatment would be inadequate.To illustrate the concepts and to tie them to real-world design choices that must be made, three operating systems have been chosen as running examples:

Windows Vista: A multitasking operating system for personal computers, workstations, and servers. This operating system incorporates many of the latest developments in op- erating system technology. In addition, Windows is one of the first important commer- cial operating systems to rely heavily on object-oriented design principles. This book covers the technology used in the most recent versions of Windows, known as Vista. UNIX: A multiuser operating system, originally intended for minicomputers, but im- plemented on a wide range of machines from powerful microcomputers to supercom- puters. Several flavors of UNIX are included. FreeBSD is a widely used system that incorporates many state-of-the-art features. Solaris is a widely used commercial ver- sion of UNIX. Linux: An open-source version of UNIX that is now widely used. These systems were chosen because of their relevance and representativeness. The dis- cussion of the example systems is distributed throughout the text rather than assembled as a single chapter or appendix. Thus, during the discussion of concurrency, the concurrency

xiii

PREFACE xv

designed to minimize student frustration while providing an interactive teaching expe- rience outside the classroom. With GOAL’s immediate feedback, hints, and pointers that map back to the textbook, students will have a more efficient and effective learn- ing experience. GOAL delivers immediate assessment and feedback via two kinds of assignments: multiple choice Homework exercises and interactive Lab work. All of these support materials are available at the Instructor Resource Center (IRC) for this textbook. To gain access to the IRC, please contact your local Prentice Hall sales repre- sentative via prenhall.com/replocator or call Prentice Hall Faculty Services at 1-800-526-0485.

INTERNET SERVICES FOR INSTRUCTORS AND STUDENTS

There is a Web site for this book that provides support for students and instructors. The site includes links to other relevant sites and a set of useful documents. See the section, “Web Site for Operating Systems: Internals and Design Principles,” preceding this Preface, for more information. The Web page is at http://williamstallings.com/OS/OS6e.html New to this edition is a set of homework problems with solutions publicly available at this Web site. Students can enhance their understanding of the material by working out the solutions to these problems and then checking their answers. An Internet mailing list has been set up so that instructors using this book can ex- change information, suggestions, and questions with each other and with the author. As soon as typos or other errors are discovered, an errata list for this book will be available at WilliamStallings.com. Finally, I maintain the Computer Science Student Resource Site at WilliamStallings.com/StudentSupport.html.

PROJECTS AND OTHER STUDENT EXERCISES

For many instructors, an important component of an OS course is a project or set of projects by which the student gets hands-on experience to reinforce concepts from the text. This book provides an unparalleled degree of support for including a projects component in the course. In the body of the text, two major programming projects are defined. The instructor’s support materials available through Prentice Hall not only includes guidance on how to as- sign and structure the projects but also includes a set of user’s manuals for various project types plus specific assignments, all written especially for this book. Instructors can assign work in the following areas:

  • Animations: Described below.
  • Simulation projects: Described below.
  • Programming projects: Described below.
  • Research projects: A series of research assignments that instruct the student to re- search a particular topic on the Internet and write a report.
  • Reading/report assignments: A list of papers that can be assigned for reading and writing a report, plus suggested assignment wording.
  • Writing assignments: A list of writing assignments to facilitate learning the material.
  • Discussion topics: These topics can be used in a classroom, chat room, or message board environment to explore certain areas in greater depth and to foster student collaboration.

xvi PREFACE

In addition, information is provided on two software packages that serve as frameworks for project implementation: Nachos for developing components of an OS, and BACI for study- ing concurrency mechanisms. This diverse set of projects and other student exercises enables the instructor to use the book as one component in a rich and varied learning experience and to tailor a course plan to meet the specific needs of the instructor and students. See Appendix C in this book for details.

ANIMATIONS AND SIMULATIONS

New to this edition is the incorporation of animations and simulations. The animations are set off by this icon. Animations provide a powerful tool for understanding the complex mechanisms of a modern OS. A total of 16 animations are used to illustrate key functions and algorithms in OS design. At the relevant point in the book, an icon indicates that a rele- vant animation is available online for student use. The IRC also provides support for assigning projects based on a set of seven simulations that cover key areas of OS design. The student can use a set of simulation packages to analyze OS design features. The simulators are all written in Java and can be run either locally as a Java application or online through a browser. The IRC includes spe- cific assignments to give to students, telling them specifically what they are to do and what results are expected.

PROGRAMMING PROJECTS

This new edition provides expanded support for programming projects. Two major pro- gramming projects, one to build a shell, or command line interpreter, and one to build a process dispatcher are described in the textbook, after Chapter 3 and after Chapter 9. The IRC provides further information and step-by-step exercises for developing the pro- grams. As an alternative, the instructor can assign a more extensive series of projects that cover many of the principles in the book. The student is provided with detailed instructions for doing each of the projects. In addition, there is a set of homework problems, which in- volve questions related to each project for the student to answer. Finally, the project manual provided at the IRC includes a series of programming pro- jects that cover a broad range of topics and that can be implemented in any suitable lan- guage on any platform.

WHAT’S NEW IN THE SIXTH EDITION

In the four years since the fifth edition of this book was published, the field has seen contin- ued innovations and improvements. In this new edition, I try to capture these changes while maintaining a broad and comprehensive coverage of the entire field. To begin the process of revision, the fifth edition of this book was extensively reviewed by a number of professors who teach the subject and by professionals working in the field. The result is that, in many

xviii PREFACE

Mathias (Utah State University), Shavakant Mishra (University of Colorado), and Richard Reese (Tarleton State University), all of whom reviewed most or all of the book. Thanks also to the people who provided detailed reviews of a one or more chapters: Vijay Nyalpelli, John Traenky, James Hartley, Ajay Kumar (Symantec), Juergen Gross, Ma- neesh Singhal (Unix Kernel Professional in India), Yao Qi, Xie Yubo, Victor Cionca, Nikhil Bhargava, and Marcos Nagamura. I would also like to thank Dave Probert, Architect in the Windows Core Kernel & Archi- tecture team at Microsoft, for the review of the material on Windows Vista and for providing the comparisons of Linux and Vista; Tigran Aivazian, author of the Linux Kernel Internals document, which is part of the Linux Documentation Project, for the review of the material on Linux 2.6; Nick Garnett of eCosCentric, for the review of the material on eCos; and Philip Levis, one of the developers of TinyOS, for the review of the material on TinyOS. Brandon Ardiente and Tina Kouri, both at the Colorado School of Mines, developed the exercises that accompany the animations referenced in the book. Adam Critchley (Universi- ty of Texas at San Antonio) developed the simulation exercises. Matt Sparks (University of Illinois at Urbana-Champaign) adapted a set of programming problems for use with this textbook. Lawrie Brown of the Australian Defence Force Academy produced the material on buffer overflow attacks. Ching-Kuang Shene (Michigan Tech University) provided the ex- amples used in the section on race conditions and reviewed the section. Tracy Camp and Keith Hellman, both at the Colorado School of Mines, developed a new set of homework problems. In addition, Fernando Ariel Gont contributed a number of homework problems; he also pro- vided detailed reviews of all of the chapters. I would also like to thank Bill Bynum (College of William and Mary) and Tracy Camp (Colorado School of Mines) for contributing Appendix G; Steve Taylor (Worcester Poly- technic Institute) for contributing the programming projects and reading/report assignments in the instructor’s manual; and Professor Tan N. Nguyen (George Mason University) for con- tributing the research projects in the instruction manual. Ian G Graham (Griffith University) contributed the two programming projects in the textbook. Oskars Rieksts (Kutztown Uni- versity) generously allowed me to make use of his lecture notes, quizzes, and projects. Finally, I would like to thank the many people responsible for the publication of the book, all of whom did their usual excellent job. This includes my editor Tracy Dunkelberger, her assistant Melinda Hagerty, production manager Rose Kernan, and supplements manager ReeAnne Davies. Also, Jake Warde of Warde Publishers managed the reviews; and Patricia M. Daly did the copy editing.

READER ’S GUIDE

0.1 Outline of This Book

0.2 A Roadmap for Readers and Instructors

0.3 Internet and Web Resources Web Sites for This Book Other Web Sites USENET Newsgroups

CHAPTER