Description
Table of contents
For Authors
User Reviews
This book, Operating System, is crafted for students pursuing Computer Science, Computer Applications, and Information Technology at undergraduate and postgraduate levels. It explores key topics such asprocess management and system security, offering insights into how operating systems manage resources and enable seamless operations. With a clear and approachable style, this book is an essential resource for understanding the core principles and operations of operating systems.
Salient Features:
Written in a simple and engaging writing style with clear explanations of complex topics.
Includes detailed discussions on interprocess communication, networking fundamentals,
and file system interface and implementation.
Covers critical concepts such as process and thread management, CPU scheduling, memory
allocation, deadlocks, and disk management.
Explains both contiguous and non-contiguous memory allocations, virtual memory, and le
system implementations to provide a thorough understanding of resource management.
Dedicated chapter on system security emphasizes modern challenges and solutions for
safeguarding operating systems and protecting data integrity.
Includes exercise questions for each chapter, a glossary, and a question bank at the end of
the book to enhance learning
This book, Operating System, is crafted for students pursuing Computer Science, Computer Applications, and Information Technology at undergraduate and postgraduate levels. It explores key topics such asprocess management and system security, offering insights into how operating systems manage resources and enable seamless operations. With a clear and approachable style, this book is an essential resource for understanding the core principles and operations of operating systems.
Salient Features:
Written in a simple and engaging writing style with clear explanations of complex topics.
Includes detailed discussions on interprocess communication, networking fundamentals,
and file system interface and implementation.
Covers critical concepts such as process and thread management, CPU scheduling, memory
allocation, deadlocks, and disk management.
Explains both contiguous and non-contiguous memory allocations, virtual memory, and le
system implementations to provide a thorough understanding of resource management.
Dedicated chapter on system security emphasizes modern challenges and solutions for
safeguarding operating systems and protecting data integrity.
Includes exercise questions for each chapter, a glossary, and a question bank at the end of
the book to enhance learning
Preface
Acknowledgement
Chapter 1 Computer System Structures 1
1.1 Computer System and its Components 1
1.2 Computer System Operation 2
1.3 Steps Involved in Instruction Execution 3
1.4 Steps Involved in System Call Execution 5
1.5 Handling Input from Keyboard 6
1.6 System Shutdown Process 6
1.7 Logon, Logoff, Shutdown, and Restart 7
1.8 Motherboard 8
1.9 Storage Hierarchy 8
1.9.1 Register 9
1.9.2 Cache Memory 9
1.9.3 Main Memory 10
1.9.4 Electronic Disk 10
1.9.5 Magnetic Disk 10
1.9.6 Optical Disk 10
1.9.7 Magnetic Tape 11
1.10 Hardware Protection 11
1.10.1 Dual-Mode of Operation 11
1.10.2 Cpu Protection 12
1.10.3 Memory Protection 12
1.10.4 I/O Protection 13
1.11 Definitions 14
Exercises 18
Chapter 2 Operating System Structures 21
2.1 Introduction to Operating System 21
2.2 Different Views of the Operating System 22
2.2.1 U user View 22
2.2.2 System View 22
2.2.3 Goals of an Operating System 23
vi Operating System
2.3 Operating System Components 23
2.3.1 Process Management 23
2.3.2 Main Memory Management 24
2.3.3 File Management 24
2.3.4 I/O Management 24
2.3.5 Secondary Storage Management 25
2.3.6 Command Interpreter System 25
2.3.7 Protection System 25
2.3.8 Networking 26
2.4 Operating System Services 26
2.5 Operating System Responsibilities 27
2.6 Operating System Structure 27
2.6.1 Layered Implementation of the Operating System 27
2.6.2 Kernel 27
2.6.3 Microkernel 28
2.6.4 Device Drivers 28
2.7 Types of OS 28
2.7.1 Mainframe Systems 28
2.7.2 Real-Time Systems 32
2.7.3 Multiprocessor / Multiprocessing / Parallel / Tightly
Coupled Systems 33
2.7.4 Clustered Systems 33
2.7.5 Distributed Systems / Loosely Coupled Systems 34
2.7.6 Handheld Systems 35
2.8 Methods to Pass Parameters to Operating Systems 36
2.9 System Design and Implementation 36
2.10 System Generation / System Configuration 36
2.11 U unix System Calls 37
2.11.1 System Calls for Process Management 37
2.11.2 System Calls for Interprocess Communication 38
2.11.3 System Calls for File Management 39
2.11.4 System Calls for File Protection 40
2.11.5 System Calls for Directory Management 40
2.11.6 System Calls for Low-Level Memory Management 42
2.12 Definitions 42
Exercises 49
Contents vii
Chapter 3 Processes and Threads 53
3.1 Process Management 53
3.1.1 Process Management 53
3.2 Process Concept 53
3.2.1 Program and Process 53
3.2.2 Process Control Block (Pcb ) / Task Control Block 54
3.2.3 Process States 55
3.2.4 Process Lists 57
3.2.5 Process Relationships 57
3.3 Process Scheduling 57
3.3.1 Scheduling Queues 58
3.3.2 Scheduler and its Types 59
3.3.3 Scheduling Decisions 60
3.3.4 Process Switch and Context Switch 61
3.3.5 Dispatcher and Dispatch Latency 61
3.4 Concurrent Processes 62
3.4.1 Forms of Interprocess Interaction 62
3.4.2 Reasons for Process Cooperation 63
3.4.3 Problems in Concurrent Cooperating Processes 63
3.5 Threads 63
3.5.1 Types of Threads 64
3.5.2 Multithreading Models 64
3.5.3 Threading Issues 67
3.6 Definitions 69
Exercises 70
Chapter 4 CPU Scheduling 73
4.1 Basic Concepts of Cpu Scheduling 73
4.1.1 Cpu-I/O Burst Cycle / Process Execution Cycle 73
4.1.2 Non-Preemptive Scheduling and Preemptive Scheduling 74
4.1.3 Scheduling Decisions 74
4.2 Scheduling Criteria 74
4.3 Cpu Scheduling Algorithms 75
4.3.1 First-Come, First-Served (Fcfs ) Scheduling 75
4.3.2 Shortest-Job-First (Sjf ) Scheduling 76
4.3.3 Shortest-Remaining-Time-First (Srtf ) Scheduling 77
4.3.4 Priority-based Scheduling 78
viii Operating System
4.3.5 Event-driven Scheduling 79
4.3.6 Round-Robin (Rr) Scheduling / Time Slice Scheduling 80
4.3.7 Multilevel Queue (Mlq ) Scheduling 81
4.3.8 Multilevel Queue Feedback (Mlqf ) Scheduling 83
4.4 Multiple-Processor Scheduling 84
4.5 Real-Time Scheduling 84
4.6 Algorithm Evaluation 86
4.6.1 Deterministic Modeling 86
4.6.2 Queuing Models 88
4.6.3 Simulation 88
4.6.4 Implementation 89
4.7 Definitions 90
Exercises 92
Chapter 5 Interprocess Interactions 99
5.1 Concurrent Processes 99
5.1.1 Relationship between Concurrent Processes 99
5.1.2 Reasons for Process Cooperation 99
5.1.3 Benefits of Concurrent Execution 100
5.1.4 Problems with Concurrent Cooperating Processes 100
5.1.5 Forms of Interprocess Interaction 100
5.2 Interprocess Communication using Messages 100
5.2.1 Issues in Message Implementation 101
5.3 Interprocess Synchronization 104
5.3.1 Need for Interprocess Synchronization and Coordination 106
5.4 The Critical-Section Problem 107
5.4.1 Requirements of the Solution to the Critical-Section Problem 107
5.4.2 Two-Process Solutions 108
5.4.3 Multiple-Process Solutions 112
5.5 Semaphores 114
5.5.1 wait( ) and signal( ) Operations 115
5.5.2 Types of Semaphores 116
5.5.3 Implementation of Semaphores 116
5.5.4 Semaphore Granularity 119
5.5.5 Conclusion 120
5.6 Classic Problems of Synchronization 120
5.6.1 The Bounded-Buffer Problem / Producer-Consumer Problem 120
Contents ix
5.6.2 The Readers-Writers Problem 123
5.6.3 The Dining-Philosophers Problem 125
5.7 Synchronization Hardware 127
5.7.1 Test-and-Set 127
5.7.2 Swap 128
5.7.3 Lock-and-Unlock 129
5.8 Monitors 130
5.9 Definitions 131
Exercises 132
Chapter 6 Deadlocks 135
6.1 Sharable, Reusable, and Consumable Resources 135
6.2 System Model 135
6.3 Deadlock Characterization 136
6.3.1 Necessary Conditions 136
6.3.2 Methods for Handling Deadlocks 137
6.4 Deadlock Prevention 137
6.4.1 Mutual Exclusion 137
6.4.2 Hold and Wait 138
6.4.3 No Preemption 138
6.4.4 Circular Wait 138
6.5 Resource Allocation Graph 139
6.6 Deadlock Avoidance 141
6.6.1 Resource Allocation Graph Algorithm 143
6.6.2 Banker’s Algorithm 145
6.7 Deadlock Detection 148
6.7.1 Wait-for Graph 149
6.7.2 Deadlock Detection Algorithm 149
6.8 Recovery from Deadlock 151
6.8.1 Rollback / Process Termination 151
6.8.2 Resource Preemption 152
6.9 Combined Approach to Deadlock Handling 152
6.10 Definitions 153
Exercises 154
Chapter 7 Introduction to Memory Management 159
7.1 Introduction 159
7.1.1 Memory Management 159
x Operating System
7.1.2 Measures for Comparing Memory Management Schemes 160
7.1.3 Ideal Memory Manager 160
7.2 Types of Addresses and Address Space 160
7.2.1 Types of Addresses 160
7.2.2 Types of Address Space 161
7.3 Address Binding 161
7.3.1 Compile Time Binding 161
7.3.2 Load Time Binding 162
7.3.3 Execution Time Binding 162
7.4 Dynamic Loading 163
7.5 Overlays 164
7.6 Dynamic Linking 166
7.7 Types of Memory Allocation 167
7.7.1 Contiguous Allocation 167
7.7.2 Non-Contiguous Allocation 167
7.8 Partitioning in Contiguous Memory Allocation 167
7.8.1 Static Partitioning 167
7.8.2 Dynamic Partitioning 167
7.9 Fragmentation 168
7.9.1 Internal Fragmentation 168
7.9.2 External Fragmentation 168
7.9.3 Page Fragmentation 168
7.9.4 Table Fragmentation 168
7.10 Relocation 169
7.10.1 Static Relocation 169
7.10.2 Dynamic Relocation 169
7.11 Comparison 170
7.12 Definitions 171
Exercises 172
Chapter 8 Contiguous Memory Allocation 173
8.1 Static Partitioned Memory Allocation 173
8.1.1 Partition Description Table 173
8.1.2 Principles of Operation 174
8.1.3 Protection 177
8.1.4 Sharing 179
8.1.5 Conclusion 179
Contents xi
8.2 Swapping 179
8.3 Relocation 181
8.3.1 Static Relocation 182
8.3.2 Dynamic Relocation 182
8.4 Dynamic Partitioned Memory Allocation 183
8.4.1 Partition Description Table 184
8.4.2 Principles of Operation 185
8.4.3 Alleviation of External Fragmentation 189
8.4.4 Protection 189
8.4.5 Sharing 189
8.4.6 Conclusion 189
8.5 Buddy System 190
8.6 Compaction 190
8.7 Comparison 192
8.8 Definitions 192
Exercises 194
Chapter 9 Non-Contiguous Memory Allocation 197
9.1 Paging 197
9.1.1 Basic Method 197
9.1.2 Hardware Support for Paging 198
9.1.3 Implementation of Page Table 199
9.1.4 Principles of Operation 200
9.1.5 Memory Protection 203
9.1.6 Conclusion 204
9.2 Structure of Page Table 204
9.2.1 Hierarchical Page Table 204
9.2.2 Hashed Page Table 206
9.2.3 Clustered Page Table 207
9.2.4 Inverted Page Table 207
9.3 Segmentation 209
9.3.1 Basic Method 209
9.3.2 Hardware Support for Segmentation 209
9.3.3 Implementation of Segment Table 210
9.3.4 Principles of Operation 211
9.3.5 Memory Protection 213
9.3.6 Conclusion 213
xii Operating System
9.4 Segmentation with Paging 213
9.5 Comparison 214
9.6 Definitions 215
Exercises 216
Chapter 10 Virtual Memory 217
10.1 Virtual Memory 217
10.1.1 Demand Paging 217
10.1.2 Hardware Support for Demand Paging 218
10.1.3 Principles of Operation 222
10.1.4 Page Fault 224
10.1.5 Page Replacement 224
10.1.6 Virtual Memory Manager 225
10.1.7 Thrashing 225
10.1.8 Conclusion 226
10.2 Virtual Memory Manager 226
10.2.1 Allocation Policy 226
10.2.2 Fetch Policy 227
10.2.3 Placement Policy 227
10.2.4 Replacement Policy 227
10.3 Allocation of Frames 228
10.3.1 Allocation Algorithms 228
10.3.2 Replacement Policies 228
10.4 Page Replacement Algorithms 228
10.4.1 First-In-First-Out (Fifo ) Algorithm 229
10.4.2 Least Recently Used (Lru) Algorithm 229
10.4.3 Optimal Replacement Algorithm 231
10.4.4 Not Recently Used (Nru) Algorithm / Clock Replacement 231
10.4.5 Counting Algorithms 233
10.5 Thrashing 233
10.5.1 Solutions to Thrashing 234
10.6 Definitions 235
Exercises 237
Chapter 11 Introduction to File Management 243
11.1 Introduction 243
11.1.1 File Types 243
11.1.2 File Attributes 244
Contents xiii
11.1.3 File Operations 245
11.1.4 Open File Table (Oft ) 245
11.1.5 File Structure 246
11.2 File Sharing 246
11.3 File Protection 247
11.3.1 Access Matrix 248
11.3.2 Access Control List (Acl ) 249
11.3.3 Capability List 249
11.3.4 Protection Rings 250
11.3.5 Locks and Keys 250
11.3.6 Passwords 251
11.4 File System 251
11.4.1 Responsibilities of File System 252
11.4.2 File System Structure / Layered Structure of File System 252
11.4.3 File Control Block (Fcb ) / Inode 253
11.4.4 File Allocation Table (Fat ) 254
11.4.5 File System Implementation 255
11.4.6 File System Operations Implementation 256
11.4.7 Partitions and Mounting 257
11.5 File System Design Issues 257
11.6 Definitions 258
Exercises 259
Chapter 12 File System Interface and Implementation 261
12.1 Introduction 261
12.2 File Access Methods 261
12.2.1 Sequential Access 262
12.2.2 Direct Access / Random Access 262
12.2.3 Indexed Access 263
12.3 File Allocation Methods 264
12.3.1 Contiguous Allocation 264
12.3.2 Linked Allocation / Chained Allocation 266
12.3.3 Indexed Allocation 268
12.4 Directory Structure / Directory Organization 270
12.4.1 Directory Organization / Types of Directories /
Directory Structure 271
xiv Operating System
12.5 Directory Implementation 276
12.5.1 Linear List 276
12.5.2 Hash Table 277
12.6 Definitions 278
Exercises 280
Chapter 13 Introduction to Disk Management 281
13.1 Disk Structure / Disk Organization 281
13.1.1 Disk Access Time 282
13.2 Disk Controller and Driver 283
13.3 Disk Cache and Unix Buffer Cache 285
13.3.1 Principles of Operation of the Disk Cache 286
13.4 Definitions 288
Exercises 291
Chapter 14 Mass Storage Structure 293
14.1 Disk Scheduling 293
14.1.1 Fcfs / Fifo Scheduling 293
14.1.2 Shortest Seek Time First (Sstf ) Scheduling 294
14.1.3 Scan Scheduling / Elevator Algorithm 295
14.1.4 C-Scan Scheduling 295
14.1.5 Look Scheduling 296
14.1.6 C-Look Scheduling 296
14.2 Disk Management 297
14.2.1 Disk Formatting 297
14.2.2 Boot Block 298
14.2.3 Bad Block 299
14.3 Disk Space Management 299
14.3.1 Free Space Management 299
14.3.2 Swap Space Management 302
14.4 Raid Structure 302
14.5 Definitions 304
Exercises 306
Chapter 15 I/O Systems 309
15.1 Introduction 309
15.2 U user and Operating System Interface 309
15.2.1 Command-Line Interface 309
Contents xv
15.2.2 Graphical User Interface 310
15.2.3 Touchscreen Interface 310
15.2.4 Choice of Interface 310
15.3 I/O Hardware 311
15.4 Methods for I/O Data Transfer 312
15.4.1 Programmed I/O 313
15.4.2 Interrupt-driven I/O 314
15.4.3 Direct Memory Access (Dma ) 314
15.4.4 Polling 316
15.5 Application of I/O Interface 316
15.5.1 Network Devices Interface 319
15.5.2 Clocks and Timers 319
15.5.3 Blocking I/O and Non-blocking I/O 320
15.6 Kernel I/O Subsystem 321
15.6.1 I/O Scheduling 321
15.6.2 Buffering 321
15.6.3 Caching 322
15.6.4 Spooling and Resource Reservation 323
15.6.5 Error Handling 323
15.6.6 Kernel Data Structures 324
15.7 Transforming I/O to Hardware Operations 325
15.7.1 Lifecycle of a Blocking Read Request 326
15.8 Performance 328
15.9 Definitions 331
Exercises 336
Chapter 16 System Security 337
16.1 The Security Problem 337
16.2 U user Authentication 338
16.2.1 Passwords 338
16.2.2 Encrypted Passwords 339
16.2.3 One-Time Passwords 339
16.2.4 Biometrics 340
16.3 System Threats 340
16.3.1 Viruses 340
16.3.2 Worms 341
16.3.3 Denial of Service 342
xvi Operating System
16.4 Program Threats 342
16.4.1 Trojan Horse 342
16.4.2 Trap Door / Back Door 343
16.4.3 Stack and Buffer Overflow 343
16.5 Intrusion Detection 343
16.5.1 Auditing and Logging 345
16.5.2 Tripwire 345
16.5.3 System Call Monitoring 345
16.6 Securing Systems and Facilities 346
16.7 Cryptography 347
16.7.1 Encryption 347
16.7.2 Authentication 348
16.7.3 Secure Socket Layer (Ssl ) 349
16.7.4 Data Encryption Standard (Des ) 350
16.7.5 Rsa Algorithm 351
16.8 Definitions 351
Exercises 355
Question Bank 357
A.K.R.S. Anusha serves as an Assistant Professor in the Department of Computer
Applications at The American College (Autonomous), Madurai. With extensive teaching
experience spanning 25 years, she has instructed students in both Arts and Science, as well
as Engineering Colleges. Anusha holds degrees in MCA and M.Phil., and has successfully
cleared the National Eligibility Test (NET) for Lectureship in Computer Science and
Applications conducted by the University Grants Commission (UGC) held in December
2012. She achieved University Gold Medal honors during her undergraduate studies.
Recognized for her contributions to education, Anusha received the “Best Teacher Award”
from the Institution of Engineering and Technology (IET) in 2012. Her academic
contributions include publications in journals and presentations at conferences. An author of textbooks such as“Software Engineering,” “Data Communication and Networking,” and “Visual Programming,” she aims to supportthe learning needs of students. Anusha’s areas of interest encompass Data Structures and Algorithms, Software Engineering, and Data Analytics.