Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Milan Milenkovic Operating Systems Concepts and Design DF56E

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

OPERATING

SYSTEMS
CONCEPTS AND DESIGN
SECOND EDITION

Milan Milenkovic
IBM Corporation

McGRAW-HILL, INC.
New York St. Louis San Francisco Auckland Bogota Caracas
Lisbon London Madrid Mexico Milan Montreal New Delhi
Paris San Juan Singapore Sydney Tokyo Toronto
CONTENTS

PREFACE

PARTI: FUNDAMENTAL C O N C E P T S , 1

1 Introduction 3

1.1 EVOLUTION OF OPERATING SYSTEMS 4


1.1.1 Serial Processing 5
1.1.2 Batch Processing 6
1.1.3 Multiprogramming 8
1.2 TYPES OF OPERATING SYSTEMS 10
1.2.1 Batch Operating Systems 10
1.2.2 Multiprogramming Operating Systems 11
Time-Sharing Systems 12
:
Real-Time Systems ' 13
Combination Operating Systems 14
1.2.3 Distributed Operating Systems 15
1.3 DIFFERENT VIEWS OF THE OPERATING SYSTEM „ 15
1.3.1 The Command-Language User's View of the.Operating
System ; 15
1.3.2 The System-Call User's View of the Operating System 17
1.4 THE JOURNEY OF A COMMAND EXECUTION ; 18
1.5 DESIGN AND IMPLEMENTATION OF OPERATING SYSTEMS ' 20
1.5.1 Functional Requirements 20
1.5.2 Implementation 22
1.6 SUMMARY , 25
OTHER READING 26

2 Processes 27

2.1 THE PROCESS CONCEPT 28


2.1.1 Implicit and Explicit Tasking ' 30
2.1.2 Process Relationship 31
2.2 SYSTEMS PROGRAMMER'S VIEW OF PROCESSES 32
2.2.1 A Multitasking Example " 32

ix
CONTENTS

2.2.2 Interprocess Synchronization 35


2.2.3 Behavior of Sample Processes 37
2.2.4 Postlude: The Systems Programmer's View of Processes 43
2.3 THE OPERATING SYSTEM'S VIEW OF PROCESSES 43
2.3.1 Process Control Block (PCB) 46
2.3.2 System State and Process Lists 47
2.3.3 Process State Transitions 47
2.3.4 Process Switch 50
2.3.5 Threads 52
2.4 OPERATING-SYSTEM SERVICES FOR PROCESS MANAGEMENT 53
CREATE (processID, attributes); 54
DELETE (processID); 54
ABORT (processID); 55
FORK/JOIN 55
SUSPEND (processID); 56
RESUME (processID); 56
DELAY (processID, time); 56
GETJJTRIBUTES (processID, attribute set); 57
CHANGE PRIORITY (processID, new .priority); 57
2.4.1 Error Returns 58
2.5 SCHEDULING . 58
2.5.1 Types of Schedulers 59
The long-term scheduler 59
The medium-term scheduler 60
The short-term scheduler 61
2.5.2 Scheduling and Performance Criteria 62
2.5.3 Scheduler Design 64
2.6 SCHEDULING ALGORITHMS 64
2.6.1 First-Come-First-Served (FCFS) Scheduling 65
2.6.2 Shortest Remaining Time Next (SRTN) Scheduling 67
2.6.3 Time-Slice Scheduling (Round Robin, RR) / 68
2.6.4 Priority-Based Preemptive Scheduling (Event Driven, ED) 75
2.6.5 Multiple-Level Queues (MLQ) Scheduling 76
2.6.6 Multiple-Level Queues With Feedback Scheduling 78
2.7 PERFORMANCE EVALUATION 78
2.7.1 FCFS (Batch) 81
2.7.2 Shortest Job First 82
2.7.3 Round Robin 82
2.8 SUMMARY 83
OTHER READING 84
EXERCISES 85

3 Interprocess Synchronization 87

.3.1 THE NEED FOR INTERPROCESS SYNCHRONIZATION 88


3.2 MUTUAL EXCLUSION 91
3.2.1 The First Algorithm 92
3.2.2 The Second Algorithm 95
CONTENTS XI

3.2.3 The Third Algorithm 97


3.3 SEMAPHORES 97
3.3.1 Semaphore Definition and Busy-Wait Implementation 99
3.3.2 Some Properties and Characteristics of Semaphores 102
Semaphore Service Discipline 103
Semaphore Granularity 103
3.4 HARDWARE SUPPORT FOR MUTUAL EXCLUSION 104
3.4.1 Pessimistic and Optimistic Concurrency Control 104
3.4.2 Disable/Enable Interrupts 106
3.4.3 Test-and-Set Instruction 107
3.4.4 Compare-and-Swap Instruction 110
3.5 QUEUING IMPLEMENTATION OF SEMAPHORES 112
3.6 CLASSICAL PROBLEMS IN CONCURRENT PROGRAMMING 114
3.6.1 The Producers/Consumers Problem 114
Producers and consumers with an unbounded buffer 115
Producers and consumers with a bounded buffer 117
3.6.2 Readers and Writers 121
3.7 SUMMARY 124
OTHER READING 125
EXERCISES 126

Interprocess Communication and Synchronization 132


4.1 CRITICAL REGION AND CONDITIONAL CRITICAL REGION 133
4.2 MONITORS 135
4.3 MESSAGES 142
4.3.1 Issues in Message Implementation 143
Naming 144
Copying 145
Synchronous vs. Asynchronous Message Exchange 146
Message Length 146
4.3.2 Interprocess Communication and Synchronization
with Messages 149
4.3.3 Interrupt Signaling via Messages 153
4.4 INTERPROCESS SYNCHRONIZATION AND COMMUNICATION IN ADA 156
4.4.1 The Entry-Accept Mechanism 158
4.4.2 The SELECT Statement 161
4.5 DEADLOCKS 166
4.5.1 Reusable and Consumable Resources 167
4.5.2 Deadlock Prevention 168
4.5.3 Deadlock Avoidance 170
Resource Request 173
Resource Release 174
4.5.4 Deadlock Detection and Recovery 175
4.5.5 Combined Approach 178
4.6 SUMMARY 179
OTHER READING 180
EXERCISES 181
Xll CONTENTS

< 5 Memory Management: Contiguous Allocation 185

. 5.1 SINGLE-PROCESS MONITOR 188


5.2 PARTITIONED MEMORY ALLOCATION-STATIC 191
5.2.1 Principles of Operation 191
5.2.2 Swapping 195
5.2.3 Relocation 197
Static Relocation ' 198
Dynamic Relocation 198
5.2.4 Protection 200
5.2.5 Sharing 202
5.2.6 Concluding Remarks , . 2 0 3
5.3 PARTITIONED MEMORY ALLOCATION-DYNAMIC 204
5.3.1 Principles of Operation 205
5.3.2 Compaction 210
5.3.3 Protection 213
5.3.4 Sharing 213
5.3.5 Concluding Remarks 216
5.4 SEGMENTATION 217
5.4.1 Principles of Operation . 217
Address Translation 219
Segment-Descriptor Caching , . 221
5.4.2 Protection 224
5.4.3 Sharing ' • 224
5.4.4 Concluding Remarks 226
5.5 SUMMARY 228
OTHER READING 228
EXERCISES '•••• 229

6 Memory Management: Noncontiguous Allocation ' 232

6.1 PAGING ^
6.1.1 Principles of Operation
6.1.2 Page Allocation
6.1.3 Hardware Support for Paging
6.1.4 Protection and Sharing
6.1.5 Concluding Remarks
• 6.2 VIRTUAL MEMORY
6.2.1 Principles of Operation
6.2.2 Instruction Interruptibility
6.2.3 Management of Virtual Memory
6.2.4 Program Behavior
6.2.5 Replacement Policies
Memory-Reference Strings
Replacement Algorithms
Global and Local Replacement Policies
6.2.6 Allocation Policies
Page-Fault Frequency (PFF)
CONTENTS Xlll

6.2.7 Working Set: A Theory for Page Replacement and


Allocation 262
6.2.8 Hardware Support and Considerations 264
6.2.9 Protection and Sharing • 266
6.2.10 Segmentation and Paging 266
6.2.11 Hierarchical Address Translation Tables and MMUs 268
6.2.12 Unix Considerations 271
6.2.13 Concluding Remarks 272
6.3 SUMMARY ' 272
OTHER READING 273
EXERCISES 274

7 File Management , 277

7.1 COMMAND-LANGUAGE USER'S VIEW OF THE FILE SYSTEM 278


7.1.1 Command-Language File Services 282
7.2 SYSTEMS PROGRAMMER'S VIEW OF THE FILE SYSTEM 285
7.3 DISK ORGANIZATION 288
7.3.1 Disk Access Time 289
7.4 DISK CONTROLLER AND DRIVER 291
7.5 OPERATING SYSTEM'S VIEW OF RLE MANAGEMENT 293
7.5.1 Directories 296
7.5.2 Disk Space Management 301
Contiguous allocation • 303
Noncontiguous allocation 305
7.5.3 An Anatomy of Disk Address Translation 310
7.5.4 File-Related System Services 316
7.5.5 Asynchronous Input/Output • 321
7.6 DISK CACHES AND UNIX BUFFER CACHE 322
7.7 A GENERALIZATION OF FILE SERVICES • 326
7.8 SUMMARY 327
OTHER READING 329
EXERCISES / 329

8 Security and Protection • 333

8.1 SECURITY THREATS AND GOALS 334


8.2 PENETRATION ATTEMPTS 335
8.3 SECURITY POLICIES AND MECHANISMS 337
8.3.1 Security Policies 337
8.3.2 Security Mechanisms and Design Principles 338
8.4 AUTHENTICATION 339
8.4.1 Passwords 340
8.4.2 Artifact-Based Authentication 341
8.4.3 Biometric Techniques 342
8.5 PROTECTION AND ACCESS CONTROL 342
8.5.1 Protection in Computer Systems 342
8.5.2 Access-Matrix Model Of Protection ' 343
8.5.3 Access Hierarchies 345
XIV CONTENTS

8.5.4 Access Lists 347


8.5.5. Capabilities 348
8.5.6 Locks and Keys 352
8.6 FORMAL MODELS OF PROTECTION 352
8.6.1 Access-Control Matrix 353
8.6.2 The Take-Grant Model 355
8.6.3 The Bell-LaPadula Model 356
8.6.4 Lattice Model of Information Flow 358
8.7 CRYPTOGRAPHY 360
8.7.1 Conventional Cryptography 362
8.7.2 The Data Encryption Standard (DES) 364
8.7.3 Public-Key Cryptography 365
The Rivest, Shamir, Adelman (RSA) Algorithm 366
Authentication 368
Digital Signatures 369
8.8 WORMS AND VIRUSES 370
8.8.1 Computer Worms 370
8.8.2 Computer Viruses 371
8.9 SUMMARY 374
OTHER READING 375
EXERCISES 376

PART II: IMPLEMENTATION 379


9 Input/Output: Principles and Programming 381
9.1 THE INPUT/OUTPUT PROBLEM
9.1.1 Asynchronous Operation
9.1.2 The Speed Gap: Processor versus Peripherals
9.2 INPUT/OUTPUT INTERFACES
9.2.1 Buffer Registers
9.2.2 Command Registers /
9.2.3 Status Registers
9.3 I/O PORT EXAMPLES
9.3.1 The Universal Synchronous/Asynchronous
Receiver/Transmitter (USART)
9.3.2 Programmable Interval Timer (PIT)
9.4 PROGRAM-CONTROLLED I/O
9.4.1 Controlling a Single Device
9.4.2 Controlling Multiple Devices: Polling
9.5 INTERRUPT-DRIVEN I/O
9.5.1 Controlling a Single Device
Context Switch
Interrupt-Service Routine (ISR)
9.5.2 Controlling Multiple Devices
Interrupt Vectoring
Levels of Interrupt Control
CONTENTS XV

Priority Levels 411


A Summary of Interrupt Processing 411
9.6 CONCURRENT I/O 412
9.7 SUMMARY , 419
OTHER READING 419
EXERCISES , 420

10 Design of a Kernel of a Multitasking Operating System (KMOS) 424

10.1 DEFINING KMOS SERVICES 426


10.2 MAJOR DESIGN DECISIONS 428
10.3 PROCESS-STATE TRANSITIONS IN KMOS 430
10.4 FUNCTIONAL SPECIFICATION OF KMOS 431
10.4.1 Process Dispatching 432
10.4.2 Interprocess Communication and Synchronization 433
Mailboxes and messages 433
SEND and RECEIVE operations 436
10.4.3 Interrupt Management 438
10.4.4 Process Management 441
Process creation 441
Delaying of a process for a specified time 442
10.4.5 System Startup 444
10.5 IMPLEMENTATION CONSIDERATIONS 446
10.5.1 Systems Implementation Languages 446
Facilities for modular program development AAf>
Access to hardware and to physical memory
addresses 449
10.5.2 Invoking the Operating System 450
Procedure call 450
Supervisor call 451
Software interrupt 452
10.6 SUMMARY 453
OTHER READING . / 453
EXERCISES 454

11 Implementation of KMOS 457

11.1 KMOS SYSTEM LISTS 458


11.2 THE READY LIST AND ITS MANIPULATION 460
11.2.1 Implementation of the Ready List in KMOS 460
11.2.2 Process Control Block 462
Management of Process Stacks 462
Structure of the Process Control Block (PCB) 463
11.2.3 Insertions Into the Ready List 464
11.2.4 The Null Process 466
11.3 INTERPROCESS COMMUNICATION AND SYNCHRONIZATION 467
11.3.1 Mailboxes and Messages 468
11.3.2 The SEND Operation 470
XVi CONTENTS

11.3.3 The RECEIVE Operation 471


11.4 PROCESS MANAGEMENT > ' 472
11.4.1 Process Creation 472
11.4.2 Process Deletion ' 474
11.4.3 Process Dispatching 474
11.4.4 Delaying a Process for a Specified Time 476
Timer Management and Delayed List 476
The DELAY Operation ' 478
Timer-Interrupt Processing 481
11.4.5 Procedure SSTACK - 483
11.5 INTERRUPT MANAGEMENT 484
11.5.1 Interrupt Mailboxes and Priorities 484
11.5.2 Interrupt Servicing in KMOS 485
11.5.3 Enabling Hardware Interrupt-Levels 488
11.6 STARTUP AND INITIAL SYSTEM CONFIGURATION 488
11.7 SUMMARY . 489
OTHER READING 489
EXERCISES 490
. KMOS SOURCE: PASCAL 491

PART III: ADVANCED TOPICS 517


12 Multiprocessor Systems 519

12.1 MOTIVATION AND CLASSIFICATION


12.1.1 Advantages of Multiprocessors
12.1.2 Multiprocessor Classification
12.2 MULTIPROCESSOR INTERCONNECTIONS
12.2.1 Bus-Oriented Systems
12.2.2 Crossbar-Connected Systems
12.2.3 Hypercubes
12.2.4 Multistage Switch-Based Systems /
12.3 TYPES OF MULTIPROCESSOR OPERATING SYSTEMS
12.3.1 Separate Supervisors
12.3.2 Master/Slave
12.3.3 Symmetric
, 12.4 MULTIPROCESSOR OS FUNCTIONS AND REQUIREMENTS
12.5 OS DESIGN AND IMPLEMENTATION ISSUES
12.5.1 Processor Management and Scheduling
Support for Multiprocessing ..•.
Allocation of Processing Resources
Scheduling
12.5.2 Memory Management
12.6 INTRODUCTION TO PARALLEL PROGRAMMING
12.6.1 Speedup
< 12.6.2 An Example of Parallel Programming:
Matrix Multiplication
CONTENTS XV11

12.6.3 FORK and JOIN in Multiprocessors' 541


12.7MULTIPROCESSOR SYNCHRONIZATION . 542
12.7.1 Test-and-Set 542
12.7.2 Compare-and-Swap 543
12.7.3 Fetch-and-Add 546
12.8 SUMMARY 547
OTHER READING 548
EXERCISES 549

13 Distributed Operating Systems: Algorithms 551


13.1 RATIONALE FOR DISTRIBUTED SYSTEMS . 552
13.1.1 Why Distributed .. 552
13.1.2 What Is Distributed 555
13.2 COMPUTER NETWORKS 556
13.2.1 Wide-Area Networks 556
13.2.2 Local-Area Networks 560
13.2.3 Communication Protocols and OSI Model 562
Physical Layer 563
Data Link Layer 563
Network Layer 564
Transport Layer 564
Session Layer 565
Presentation Layer 565
Application Layer 565
13.3 ALGORITHMS FOR DISTRIBUTED PROCESSING 565
13.3.1 The Environment and Common Assumptions 566
13.3.2 Time and Ordering of Events . 568
13.3.3 Mutual Exclusion in Distributed Systems 569
Lamport's Algorithm • 571
Ricart and Agrawala 's Algorithm 571
13.3.4 Transactions ^ 572
13.3.5 Distributed Concurrency Control and Deadlocks 573
13.4 COPING WITH FAILURES 576
13.4.1 Failures in Distributed Systems 577
13.4.2 Election of a Successor 578
13.4.3 Regeneration of a Lost Token 580
13.4.4 Reaching Agreement 581
13.5 SUMMARY 586
OTHER READING 586
EXERCISES ' 587

14 Distributed Operating Systems: Implementation ' 589


14.1 MODELS OF DISTRIBUTED SYSTEMS 590
14.1.1 The Host-based Model 591
14.1.2 The Processor Pool Model 591
14.1.3 The Workstation/Server Model 591
XV111 CONTENTS

14.1.4 The Integrated Model 594


14.2 NAMING 594
14.2.1 Static Maps 596
14.2.2 Broadcasting 597
14.2.3 Name Servers 597
14.2.4 Prefix Tables 598
14.3 PROCESS MIGRATION 599
14.4 REMOTE PROCEDURE CALLS 602
14.4.1 Transfer of Control 603
14.4.2 Binding 605
14.4.3 Flow of Data 606
14.4.4 RPC Server Design Issues 607
14.4.5 RPC versus Message Passing 608
14.5 DISTRIBUTED SHARED MEMORY 609
14.6 DISTRIBUTED FILE SYSTEMS 611
14.6.1 Client/Server Division of Labor 612
14.6.2 File Caching and Consistency Semantics 615
14.6.3 Statefulness and Performance 618
14.6.4 Fault Tolerance 619
14.7 SUMMARY 620
OTHER READING 622
EXERCISES 622

PART IV: CASE STUDIES 625


15 Case Studies 627

15.1 PC-DOS (MS-DOS) OPERATING SYSTEM 628


15.1.1 Command-Language User's View of PC-DOS 628
15.1.2 System-Call User's View of PC-DOS 630
15.1.3 PC-DOS Implementation 632
15.1.4 PC-DOS Summary •" 634
15.2 THE UNIX OPERATING SYSTEM 635
15.2.1 Command-Language User's View of Unix 636
15.2.2 System-Call User's View of Unix 642
15.2.3 Implementation of Unix 645
15.2.4 Unix Summary 650
15.3 iRMX 86 OPERATING SYSTEM 650
15.3.1 Command-Language User's View of iRMX 86 652
15.3.2 System-Call User's View of iRMX 86 653
15.3.3 Implementation of iRMX 86 659
15.3.4 iRMX 86 Summary 662
15.4 DESIGN OF A REMOTE-TELEMETRY UNIT (RTU) 662
15.4.1 Computer Data-Acquisition and Control Systems 663
15.4.2 The Role of a Remote-Telemetry Unit (RTU) 666
15.4.3 Functional Organization and Activities of an RTU 668
CONTENTS Xix

15.4.4 RTU Software Organization (Processes) 671


15.4.5 RTU Data Structures and Interprocess Communication 674
15.4.6 Operation of RTU Processes 676
15.4.7 RTU Processes and KMOS 680
15.4.8 Concluding Remarks 681
OTHER READING 682

Appendix A: KMOS Sampler: Pascal 684

Appendix B: KMOS Source: C 693

Appendix C: KMOS Sampler: C 717

Bibliography 724

Index 741

You might also like