Synopses & Reviews
In order to thoroughly understand what makes Linux tick and why it works so well on a wide variety of systems, you need to delve deep into the heart of the kernel. The kernel handles all interactions between the CPU and the external world, and determines which programs will share processor time, in what order. It manages limited memory so well that hundreds of processes can share the system efficiently, and expertly organizes data transfers so that the CPU isn't kept waiting any longer than necessary for the relatively slow disks.
The third edition of Understanding the Linux Kernel takes you on a guided tour of the most significant data structures, algorithms, and programming tricks used in the kernel. Probing beyond superficial features, the authors offer valuable insights to people who want to know how things really work inside their machine. Important Intel-specific features are discussed. Relevant segments of code are dissected line by line. But the book covers more than just the functioning of the code; it explains the theoretical underpinnings of why Linux does things the way it does.
This edition of the book covers Version 2.6, which has seen significant changes to nearly every kernel subsystem, particularly in the areas of memory management and block devices. The book focuses on the following topics:
- Memory management, including file buffering, process swapping, and Direct memory Access (DMA)
- The Virtual Filesystem layer and the Second and Third Extended Filesystems
- Process creation and scheduling
- Signals, interrupts, and the essential interfaces to device drivers
- Synchronization within the kernel
- Interprocess Communication (IPC)
- Program execution
Understanding the Linux Kernel will acquaint you with all the inner workings of Linux, but it's more than just an academic exercise. You'll learn what conditions bring out Linux's best performance, and you'll see how it meets the challenge of providing good system response during process scheduling, file access, and memory management in a wide variety of environments. This book will help you make the most of your Linux system.
About the Author
Daniel P. Bovet got a Ph.D. in computer science at UCLA in 1968 and is now full Professor at the University of Rome, "Tor Vergata," Italy. He had to wait over 25 years before being able to teach an operating system course in a proper manner because of the lack of source code for modern, well-designed systems. Now, thanks to cheap PCs and to Linux, Marco and Dan are able to cover all the facets of an operating system from booting to tuning and are able to hand out tough, satisfying homework to their students. (These young guys working at home on their PCs are really spoiled; they never had to fight with punched cards.) In fact, Dan was so fascinated by the accomplishments of Linus Torvalds and his followers that he spent the last few years trying to unravel some of Linux's mysteries. It seemed natural, after all that work, to write a book about what he found.
Marco Cesati received a degree in mathematics in 1992 and a Ph.D. in computer science (University of Rome, "La Sapienza") in 1995. He is now a research assistant in the computer science department of the School of Engineering (University of Rome, "Tor Vergata"). In the past, he served as system administrator and Unix programmer for the university (as a Ph.D. student) and for several institutions (as a consultant).
Table of Contents
Preface; The Audience for This Book; Organization of the Material; Level of Description; Overview of the Book; Background Information; Conventions in This Book; How to Contact Us; Safari® Enabled; Acknowledgments; Chapter 1: Introduction; 1.1 Linux Versus Other Unix-Like Kernels; 1.2 Hardware Dependency; 1.3 Linux Versions; 1.4 Basic Operating System Concepts; 1.5 An Overview of the Unix Filesystem; 1.6 An Overview of Unix Kernels; Chapter 2: Memory Addressing; 2.1 Memory Addresses; 2.2 Segmentation in Hardware; 2.3 Segmentation in Linux; 2.4 Paging in Hardware; 2.5 Paging in Linux; Chapter 3: Processes; 3.1 Processes, Lightweight Processes, and Threads; 3.2 Process Descriptor; 3.3 Process Switch; 3.4 Creating Processes; 3.5 Destroying Processes; Chapter 4: Interrupts and Exceptions; 4.1 The Role of Interrupt Signals; 4.2 Interrupts and Exceptions; 4.3 Nested Execution of Exception and Interrupt Handlers; 4.4 Initializing the Interrupt Descriptor Table; 4.5 Exception Handling; 4.6 Interrupt Handling; 4.7 Softirqs and Tasklets; 4.8 Work Queues; 4.9 Returning from Interrupts and Exceptions; Chapter 5: Kernel Synchronization; 5.1 How the Kernel Services Requests; 5.2 Synchronization Primitives; 5.3 Synchronizing Accesses to Kernel Data Structures; 5.4 Examples of Race Condition Prevention; Chapter 6: Timing Measurements; 6.1 Clock and Timer Circuits; 6.2 The Linux Timekeeping Architecture; 6.3 Updating the Time and Date; 6.4 Updating System Statistics; 6.5 Software Timers and Delay Functions; 6.6 System Calls Related to Timing Measurements; Chapter 7: Process Scheduling; 7.1 Scheduling Policy; 7.2 The Scheduling Algorithm; 7.3 Data Structures Used by the Scheduler; 7.4 Functions Used by the Scheduler; 7.5 Runqueue Balancing in Multiprocessor Systems; 7.6 System Calls Related to Scheduling; Chapter 8: Memory Management; 8.1 Page Frame Management; 8.2 Memory Area Management; 8.3 Noncontiguous Memory Area Management; Chapter 9: Process Address Space; 9.1 The Process's Address Space; 9.2 The Memory Descriptor; 9.3 Memory Regions; 9.4 Page Fault Exception Handler; 9.5 Creating and Deleting a Process Address Space; 9.6 Managing the Heap; Chapter 10: System Calls; 10.1 POSIX APIs and System Calls; 10.2 System Call Handler and Service Routines; 10.3 Entering and Exiting a System Call; 10.4 Parameter Passing; 10.5 Kernel Wrapper Routines; Chapter 11: Signals; 11.1 The Role of Signals; 11.2 Generating a Signal; 11.3 Delivering a Signal; 11.4 System Calls Related to Signal Handling; Chapter 12: The Virtual Filesystem; 12.1 The Role of the Virtual Filesystem (VFS); 12.2 VFS Data Structures; 12.3 Filesystem Types; 12.4 Filesystem Handling; 12.5 Pathname Lookup; 12.6 Implementations of VFS System Calls; 12.7 File Locking; Chapter 13: I/O Architecture and Device Drivers; 13.1 I/O Architecture; 13.2 The Device Driver Model; 13.3 Device Files; 13.4 Device Drivers; 13.5 Character Device Drivers; Chapter 14: Block Device Drivers; 14.1 Block Devices Handling; 14.2 The Generic Block Layer; 14.3 The I/O Scheduler; 14.4 Block Device Drivers; 14.5 Opening a Block Device File; Chapter 15: The Page Cache; 15.1 The Page Cache; 15.2 Storing Blocks in the Page Cache; 15.3 Writing Dirty Pages to Disk; 15.4 The sync( ), fsync( ), and fdatasync( ) System Calls; Chapter 16: Accessing Files; 16.1 Reading and Writing a File; 16.2 Memory Mapping; 16.3 Direct I/O Transfers; 16.4 Asynchronous I/O; Chapter 17: Page Frame Reclaiming; 17.1 The Page Frame Reclaiming Algorithm; 17.2 Reverse Mapping; 17.3 Implementing the PFRA; 17.4 Swapping; Chapter 18: The Ext2 and Ext3 Filesystems; 18.1 General Characteristics of Ext2; 18.2 Ext2 Disk Data Structures; 18.3 Ext2 Memory Data Structures; 18.4 Creating the Ext2 Filesystem; 18.5 Ext2 Methods; 18.6 Managing Ext2 Disk Space; 18.7 The Ext3 Filesystem; Chapter 19: Process Communication; 19.1 Pipes; 19.2 FIFOs; 19.3 System V IPC; 19.4 POSIX Message Queues; Chapter 20: Program ExZecution; 20.1 Executable Files; 20.2 Executable Formats; 20.3 Execution Domains; 20.4 The exec Functions; Appendix A: System Startup; A.1 Prehistoric