Docsity

Operating system concept essential, Study notes of Operating Systems

Toggle sidebar
bg1
OPERATING
SYSTEM
CONCEPTS
Abraham Silberschatz
Peter Baer Galvin
Greg Gagne
Second Edition
Essentials
Cover Design Credit: Madelyn Lesure
Cover Images Credit: © Susan Cyr
Did you know this book is available as a Wiley E-Text?
E-textbooks offer the complete content of the printed textbook on the device
of your preference—computer, iPad, tablet, or smartphone—giving you
the freedom to read or study anytime, anywhere.
For Instructors:
Wiley E-Texts allow you to save your
teaching notes within the digital version
of the printed textbook. Now you can
have one digital library to take to and
from the classroom for all of the courses
you teach.
For Students:
Wiley E-Texts offer a more affordable
alternative to traditional print. You can
access course materials and content
anytime, anywhere through a user
experience that makes learning
rewarding.
How Can Students Purchase E-textbooks?
Via your campus bookstore:
Wiley E-Text: Powered by VitalSource
ISBN 978-1-118-84392-5
Directly from online retailers:
Including Wiley.com, Amazon,
Barnes & Noble, and CourseSmart®
For information about this title, including additional ordering options and accompanying resources, visit:
www.wiley.com/college/silberschatz or contact your Wiley representative.
✓ Search content
✓ Take notes
✓ Highlight key materials
✓ Organize all your work in one place
Save At Least
50% Off Printed Textbook Costs!
Wiley’sDigitalAdvantage
www.wiley.com/college/silberschatz
OPERATING SYSTEM CONCEPTS
Silberschatz Galvin Gagne
Second
Edition
Essentials
9 781118 804926
90000
ISBN 978-1-118-80492-6
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Operating system concept essential and more Study notes Operating Systems in PDF only on Docsity!

OPERATING

SYSTEM

CONCEPTS

Abraham Silberschatz

Peter Baer Galvin

Greg Gagne

Second Edition

Essentials

This page is intentionally left blank

ABRAHAM SILBERSCHATZ

Yale University

PETER BAER GALVIN

Corporate Technologies, Inc.

GREG GAGNE

Westminster College

Operating

System Concepts

Essential s

Second Edition

To my children, Lemor, Sivan, and Aaron

and my Nicolette

Avi Silberschatz

To my wife, Carla,

and my children, Gwen, Owen, and Maddie

Peter Baer Galvin

To my wife, Pat,

and our sons, Tom and Jay

Greg Gagne

This page is intentionally left blank

viii Preface

Computing Society and the Association for Computing Machinery (ACM).

Consideration was also given to the feedback provided by the reviewers of

the text, along with the many comments and suggestions we received from

readers of our previous editions and from our current and former students.

Content of This Book

The text is organized in six major parts:

  • Overview. Chapters 1 and 2 explain what operating systems are, what

they do, and how they are designed and constructed. These chapters

discuss what the common features of an operating system are and what an

operating system does for the user. We include coverage of both traditional

PC and server operating systems, as well as operating systems for mobile

devices. The presentation is motivational and explanatory in nature. We

have avoided a discussion of how things are done internally in these

chapters. Therefore, they are suitable for individual readers or for students

in lower-level classes who want to learn what an operating system is

without getting into the details of the internal algorithms.

  • Process management. Chapters 3 through 6 describe the process concept

and concurrency as the heart of modern operating systems. A process

is the unit of work in a system. Such a system consists of a collection

of concurrently executing processes, some of which are operating-system

processes (those that execute system code) and the rest of which are user

processes (those that execute user code). These chapters cover methods for

process scheduling, interprocess communication, process synchronization,

and deadlock handling. Also included is a discussion of threads, as well

as an examination of issues related to multicore systems and parallel

programming.

  • Memory management. Chapters 7 and 8 deal with the management of

main memory during the execution of a process. To improve both the

utilization of the CPU and the speed of its response to its users, the

computer must keep several processes in memory. There are many different

memory-management schemes, reflecting various approaches to memory

management, and the effectiveness of a particular algorithm depends on

the situation.

  • Storage management. Chapters 9 through 12 describe how mass storage,

the file system, and I/O are handled in a modern computer system. The

file system provides the mechanism for on-line storage of and access

to both data and programs. We describe the classic internal algorithms

and structures of storage management and provide a firm practical

understanding of the algorithms used—their properties, advantages, and

disadvantages. Since the I/O devices that attach to a computer vary widely,

the operating system needs to provide a wide range of functionality to

applications to allow them to control all aspects of these devices. We

discuss system I/O in depth, including I/O system design, interfaces, and

Preface ix

internal system structures and functions. In many ways, I/O devices are

the slowest major components of the computer. Because they represent a

performance bottleneck, we also examine performance issues associated

with I/O devices.

  • Protection and security. Chapters 13 and 14 discuss the mechanisms

necessary for the protection and security of computer systems. The

processes in an operating system must be protected from one another’s

activities, and to provide such protection, we must ensure that only

processes that have gained proper authorization from the operating system

can operate on the files, memory, CPU, and other resources of the system.

Protection is a mechanism for controlling the access of programs, processes,

or users to computer-system resources. This mechanism must provide a

means of specifying the controls to be imposed, as well as a means of

enforcement. Security protects the integrity of the information stored in

the system (both data and code), as well as the physical resources of the

system, from unauthorized access, malicious destruction or alteration, and

accidental introduction of inconsistency.

  • Case studies. Chapter 15 in the text, along with Appendices A and B

(which are available on http://www.os-book.com), present detailed case

studies of real operating systems, including Linux, Free BSD , and Mach.

Coverage of Linux is presented throughout this text; however, the case

studies provide much more detail.

Operating System Essentials

We have based Operating System Essentials on the Ninth Edition of Operating

System Concepts , published in 2012. Our intention behind developing this

Essentials edition is to provide readers with a textbook that focuses on the

core concepts that underlie contemporary operating systems. By focusing on

core concepts, we believe students are able to grasp the essential features of a

modern operating system more easily and more quickly.

To achieve this, Operating System Essentials omits the following coverage

from the Ninth Edition of Operating System Concepts :

1. We removed Chapter 7—Deadlocks—and instead offer a detailed

overview of deadlocks in Chapter 6.

2. We removed Chapter 16—Virtual Machines.

3. We removed Chapter 17—Distributed Systems.

4. We removed Chapter 19—Windows 7.

5. We removed Chapter 20—Influential Operating Systems.

For those that wish to pursue a more comprehensive study of operating

systems, we refer you to the Ninth Edition of Operating System Concepts , and

in the following we describe the changes relevant to that edition.

Preface xi

  • Chapter 8, Virtual Memory,^ updates kernel memory management to

include the Linux SLUB and SLOB memory allocators.

  • Chapter 9, Mass-Storage Structure^ (previously Chapter 11), adds coverage

of solid-state disks.

  • Chapter 10, File-System Interface^ (previously Chapter 9), is updated with

information about current technologies.

  • Chapter 11, File-System Implementation^ (previously Chapter 10), is

updated with coverage of current technologies.

  • Chapter 12, I/O,^ updates technologies and performance numbers, expands

coverage of synchronous/asynchronous and blocking/nonblocking I/O,

and adds a section on vectored I/O.

  • Chapter 13, Protection,^ has no major changes.
  • Chapter 14, Security, has a revised cryptography section with modern

notation and an improved explanation of various encryption methods and

their uses. The chapter also includes new coverage of Windows 7 security.

  • Chapter 15, The Linux System, has been updated to cover the Linux 3.

kernel.

Programming Environments

This book uses examples of many real-world operating systems to illustrate

fundamental operating-system concepts. Particular attention is paid to Linux

and Microsoft Windows, but we also refer to various versions of UNIX

(including Solaris, BSD , and Mac OS X ).

The text also provides several example programs written in C and

Java. These programs are intended to run in the following programming

environments:

  • POSIX.^ POSIX^ (which stands for^ Portable Operating System Interface ) repre-

sents a set of standards implemented primarily for UNIX -based operating

systems. Although Windows systems can also run certain POSIX programs,

our coverage of POSIX focuses on UNIX and Linux systems. POSIX -compliant

systems must implement the POSIX core standard ( POSIX .1); Linux, Solaris,

and Mac OS X are examples of POSIX -compliant systems. POSIX also

defines several extensions to the standards, including real-time extensions

(POSIX 1.b) and an extension for a threads library ( POSIX 1.c, better known

as Pthreads). We provide several programming examples written in C

illustrating the POSIX base API, as well as Pthreads and the extensions for

real-time programming. These example programs were tested on Linux 2.

and 3.2 systems, Mac OS X 10.7, and Solaris 10 using the gcc 4.0 compiler.

  • Java. Java is a widely used programming language with a rich^ API^ and

built-in language support for thread creation and management. Java

programs run on any operating system supporting a Java virtual machine

(or JVM). We illustrate various operating-system and networking concepts

with Java programs tested using the Java 1.6 JVM.

xii Preface

  • Windows systems. The primary programming environment for Windows

systems is the Windows API, which provides a comprehensive set of func-

tions for managing processes, threads, memory, and peripheral devices.

We supply several C programs illustrating the use of this API. Programs

were tested on systems running Windows XP and Windows 7.

We have chosen these three programming environments because we

believe that they best represent the two most popular operating-system models

—Windows and UNIX /Linux—along with the widely used Java environment.

Most programming examples are written in C, and we expect readers to be

comfortable with this language. Readers familiar with both the C and Java

languages should easily understand most programs provided in this text.

In some instances—such as thread creation—we illustrate a specific

concept using all three programming environments, allowing the reader

to contrast the three different libraries as they address the same task. In

other situations, we may use just one of the APIs to demonstrate a concept.

For example, we illustrate shared memory using just the POSIX API; socket

programming in TCP/IP is highlighted using the Java API.

Linux Virtual Machine

To help students gain a better understanding of the Linux system, we provide

a Linux virtual machine, including the Linux source code, that is available for

download from the website supporting this text (http://www.os-book.com).

This virtual machine also includes a gcc development environment with

compilers and editors. Most of the programming assignments in the book

can be completed on this virtual machine, with the exception of assignments

that require Java or the Windows API.

We also provide three programming assignments that modify the Linux

kernel through kernel modules:

1. Adding a basic kernel module to the Linux kernel.

2. Adding a kernel module that uses various kernel data structures.

3. Adding a kernel module that iterates over tasks in a running Linux

system.

Over time it is our intention to add additional kernel module assignments on

the supporting website.

Supporting Website

When you visit the website supporting this text at http://www.os-book.com,

you can download the following resources:

  • Linux virtual machine
  • C and Java source code

xiv Preface

Contacting Us

We have endeavored to eliminate typos, bugs, and the like from the text. But,

as in new releases of software, bugs almost surely remain. An up-to-date errata

list is accessible from the book’s website. We would be grateful if you would

notify us of any errors or omissions in the book that are not on the current list

of errata.

We would be glad to receive suggestions on improvements to the book.

We also welcome any contributions to the book website that could be of

use to other readers, such as programming exercises, project suggestions,

on-line labs and tutorials, and teaching tips. E-mail should be addressed to

[email protected].

Acknowledgments

This book is derived from the previous editions, the first three of which

were coauthored by James Peterson. Others who helped us with previous

editions include Hamid Arabnia, Rida Bazzi, Randy Bentson, David Black,

Joseph Boykin, Jeff Brumfield, Gael Buckley, Roy Campbell, P. C. Capon, John

Carpenter, Gil Carrick, Thomas Casavant, Bart Childs, Ajoy Kumar Datta,

Joe Deck, Sudarshan K. Dhall, Thomas Doeppner, Caleb Drake, M. Racsit

Eskicioglu, Hans Flack, Robert Fowler, G. Scott Graham, Richard Guy, Max ˘

Hailperin, Rebecca Hartman, Wayne Hathaway, Christopher Haynes, Don

Heller, Bruce Hillyer, Mark Holliday, Dean Hougen, Michael Huang, Ahmed

Kamel, Morty Kewstel, Richard Kieburtz, Carol Kroll, Morty Kwestel, Thomas

LeBlanc, John Leggett, Jerrold Leichter, Ted Leung, Gary Lippman, Carolyn

Miller, Michael Molloy, Euripides Montagne, Yoichi Muraoka, Jim M. Ng,

Banu Ozden, Ed Posnak, Boris Putanec, Charles Qualline, John Quarterman,¨

Mike Reiter, Gustavo Rodriguez-Rivera, Carolyn J. C. Schauble, Thomas P.

Skinner, Yannis Smaragdakis, Jesse St. Laurent, John Stankovic, Adam Stauffer,

Steven Stepanek, John Sterling, Hal Stern, Louis Stevens, Pete Thomas, David

Umbaugh, Steve Vinoski, Tommy Wagner, Larry L. Wear, John Werth, James

M. Westall, J. S. Weston, and Yang Xiang

Robert Love updated both Chapter 15 and the Linux coverage throughout

the text, as well as answering many of our Android-related questions. Jonathan

Katz contributed to Chapter 14. Salahuddin Khan updated Section 14.9 to

provide new coverage of Windows 7 security.

Chapter 15 was derived from an unpublished manuscript by Stephen

Tweedie. Cliff Martin helped with updating the UNIX appendix to cover

Free BSD. Some of the exercises and accompanying solutions were supplied by

Arvind Krishnamurthy. Andrew DeNicola prepared the student study guide

that is available on our website. Some of the slides were prepeared by Marilyn

Turnamian.

Mike Shapiro, Bryan Cantrill, and Jim Mauro answered several Solaris-

related questions, and Bryan Cantrill from Sun Microsystems helped with the

ZFS coverage. Josh Dees and Rob Reynolds contributed coverage of Microsoft’s

NET. The project for POSIX message queues was contributed by John Trono of

Saint Michael’s College in Colchester, Vermont.

Preface xv

Judi Paige helped with generating figures and presentation of slides.

Thomas Gagne prepared new artwork for this edition. Mark Wogahn has made

sure that the software to produce this book (LATEX and fonts) works properly.

Ranjan Kumar Meher rewrote some of the LATEX software used in the production

of this new text.

Our Executive Editor, Beth Lang Golub, provided expert guidance as we

prepared this edition. She was assisted by Katherine Willis, who managed

many details of the project smoothly. The Senior Production Editor, Joyce Poh,

was instrumental in handling all the production details.

The cover illustrator was Susan Cyr, and the cover designer was Madelyn

Lesure. Beverly Peavler copy-edited the manuscript. The freelance proofreader

was Katrina Avery; the freelance indexer was WordCo, Inc.

Abraham Silberschatz, New Haven, CT, 2013

Peter Baer Galvin, Boston, MA, 2013

Greg Gagne, Salt Lake City, UT, 2013

Contents

PART ONE OVERVIEW

PART TWO PROCESS MANAGEMENT

xviii Contents

PART THREE MEMORY MANAGEMENT

  • 1 1 What Operating Systems Do Chapter 1 Introduction
  • 1 2 Computer-System Organization
  • 1 3 Computer-System Architecture
  • 1 .4 Operating-System Structure
  • 1 .5 Operating-System Operations
  • 1 .6 Process Management
  • 1 .7 Memory Management
  • 1 .8 Storage Management - 1 .9 Protection and Security - 1 .10 Kernel Data Structures - 1 11 Computing Environments - 1 .12 Open-Source Operating Systems - 1 .13 Summary - Exercises - Bibliographical Notes
  • 2 .1 Operating-System Services Chapter 2 Operating-System Structures
    • Interface 2 2 User and Operating-System
  • 2 .3 System Calls
  • 2 4 Types of System Calls
  • 2 .5 System Programs
    • Implementation 2 .6 Operating-System Design and - 2 .7 Operating-System Structure - 2 .8 Operating-System Debugging - 2 .9 Operating-System Generation
      • 2 .10 System Boot
      • 2 .11 Summary - Exercises - Bibliographical Notes
  • 3 .1 Process Concept Chapter 3 Processes
  • 3 .2 Process Scheduling
  • 3 .3 Operations on Processes
  • 3 4 Interprocess Communication
  • 3 .5 Examples of IPC Systems - Server Systems 3 6 Communication in Client– - 3 .7 Summary - Exercises - Bibliographical Notes
  • 4 .1 Overview Chapter 4 Threads
  • 4 .2 Multicore Programming
  • 4 .3 Multithreading Models
  • 4 4 Thread Libraries
  • 4 5 Implicit Threading - 4 6 Threading Issues - 4 .7 Operating-System Examples - 4 .8 Summary - Exercises - Bibliographical Notes
  • 5 .1 Background Chapter 5 Process Synchronization
  • 5 2 The Critical-Section Problem
  • 5 .3 Peterson’s Solution
  • 5 .4 Synchronization Hardware
  • 5 .5 Mutex Locks
  • 5 .6 Semaphores
    • Synchronization 5 7 Classic Problems of - 5 .8 Monitors - 5 .9 Synchronization Examples
      • 5 .10 Alternative Approaches
      • 5 .11 Deadlocks
      • 5 .12 Summary - Exercises - Bibliographical Notes
  • 6 .1 Basic Concepts Chapter 6 CPU Scheduling
  • 6 .2 Scheduling Criteria
  • 6 .3 Scheduling Algorithms
  • 6 4 Thread Scheduling
  • 6 .5 Multiple-Processor Scheduling
  • 6 .6 Real-Time CPU Scheduling - 6 .7 Operating-System Examples - 6 .8 Algorithm Evaluation - 6 .9 Summary - Exercises - Bibliographical Notes
  • 7 .1 Background Chapter 7 Main Memory
  • 7 .2 Swapping
  • 7 3 Contiguous Memory Allocation
  • 7 .4 Segmentation
  • 7 .5 Paging
  • 7 .6 Structure of the Page Table - Architectures 7 .7 Example: Intel 32 and 64-bit - 7 .8 Example: ARM Architecture - 7 .9 Summary - Exercises - Bibliographical Notes
  • 8 .1 Background Chapter 8 Virtual Memory
  • 8 .2 Demand Paging
  • 8 3 Copy-on-Write
  • 8 .4 Page Replacement
  • 8 .5 Allocation of Frames
  • 8 6 Thrashing
  • 8 .7 Memory-Mapped Files - 8 .8 Allocating Kernel Memory - 8 .9 Other Considerations - 8 .10 Operating-System Examples - 8 .11 Summary - Exercises - Bibliographical Notes