3rd EditionFROMIOPORTSTOPROCESSMANAGEMENT?Understanding theaLINUXKERNELO'REILLYDANIELPBOVET&MARCOCESAT
1
UnderstandingtheLinuxKernel,3rdEditionLINUXByDaniel P.Bovet, Marco CesatiKERNELPublisher: o'ReillyPubDate:November2005ISBN:0-596-00565-2Pages:942OverviewInordertothoroughlyunderstandwhatmakesLinuxtick andwhyitworkssowell onawidevarietyof systems,youneedtodelvedeepintotheheartof thekernel.Thekernel handlesall interactionsbetweentheCPUandtheexternal world,anddetermineswhichprogramswill shareprocessortime,in what order. It manages limited memory so well that hundreds of processes can share thesystem efficiently,and expertly organizes data transfers so that the Cpu isn't kept waiting anylongerthannecessaryfortherelativelyslowdisks.The third edition of Understanding the Linux Kernel takes you on a guided tour of the mostsignificantdatastructures,algorithms,andprogrammingtricksusedinthekernel.Probingbeyondsuperficial features,the authors offervaluable insights topeople who want toknow how thingsreally work inside their machine. Important Intel-specific features are discussed. Relevantsegmentsof codearedissected lineby line.Butthebookcoversmorethanjustthefunctioningofthe code; it explains the theoretical underpinnings of why Linux does things the way it doesThis edition of the book covers Version 2.6, which has seen significant changes to nearly everykernel subsystem,particularly in the areas ofmemory managementand block devices.The bookfocuses onthefollowingtopics:Memory management,including file buffering,process swapping,and Direct memoryAccess (DMA)TheVirtualFilesystemlayerandtheSecondandThirdExtendedFilesystems·ProcesscreationandschedulingSignals, interrupts, andthe essential interfaces todevicedriversTimingSynchronizationwithinthekernelInterprocessCommunication(IPC)2
2 Understanding the Linux Kernel, 3rd Edition By Daniel P. Bovet, Marco Cesati . Publisher: O'Reilly Pub Date: November 2005 ISBN: 0-596-00565-2 Pages: 942 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 Timing Synchronization within the kernel Interprocess Communication (IPC)
Programexecution?UnderstandingtheLinuxKernelwill acquaintyouwithall theinnerworkingsof Linux,but it'smorethan justan academic exercise.You'll learn what conditions bring out Linux'sbest performance,andyou'll see how itmeets thechallenge of providinggood systemresponse during processscheduling,fileaccess,andmemorymanagementinawidevarietyofenvironments.Thisbookwillhelp youmakethemostofyourLinuxsystem.3
3 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
Table of ContentsIndexCopyrightPrefaceThe Audiencefor This BookOrganization of the MaterialLevelof DescriptionOverviewof theBookBackground InformationConventionsinThisBookHow to Contact UsSafari? EnabledAcknowledgmentsChapter1.IntroductionSection1.1.LinuxVersusOtherUnix-LikeKernelsSection 1.2.Hardware DependencySection 1.3. Linux VersionsSection1.4.BasicOperatingSystemConceptsSection1.5.AnOverviewoftheUnixFilesystemSection1.6.AnOverviewofUnixKernelsChapter2.MemoryAddressingSection2.1.MemoryAddressesSection 2.2. Segmentation in HardwareSection2.3.Segmentation in LinuxSection 2.4.Paging in HardwareSection 2.5.Paging in LinuxChapter3.ProcessesSection 3.1. Processes, Lightweight Processes,and ThreadsSection3.2.ProcessDescriptorSection 3.3. Process SwitchSection 3.4.Creating ProcessesSection3.5.Destroying ProcessesChapter4.Interrupts and ExceptionsSection4.1.TheRoleof Interrupt SignalsSection4.2.InterruptsandExceptionsSection 4.3.Nested Execution of Exception and Interrupt HandlersSection4.4.InitializingtheInterruptDescriptorTableSection4.5.ExceptionHandling4
4 Table of Contents | Index Copyright 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 Section 1.1. Linux Versus Other Unix-Like Kernels Section 1.2. Hardware Dependency Section 1.3. Linux Versions Section 1.4. Basic Operating System Concepts Section 1.5. An Overview of the Unix Filesystem Section 1.6. An Overview of Unix Kernels Chapter 2. Memory Addressing Section 2.1. Memory Addresses Section 2.2. Segmentation in Hardware Section 2.3. Segmentation in Linux Section 2.4. Paging in Hardware Section 2.5. Paging in Linux Chapter 3. Processes Section 3.1. Processes, Lightweight Processes, and Threads Section 3.2. Process Descriptor Section 3.3. Process Switch Section 3.4. Creating Processes Section 3.5. Destroying Processes Chapter 4. Interrupts and Exceptions Section 4.1. The Role of Interrupt Signals Section 4.2. Interrupts and Exceptions Section 4.3. Nested Execution of Exception and Interrupt Handlers Section 4.4. Initializing the Interrupt Descriptor Table Section 4.5. Exception Handling
Section4.6.InterruptHandlingSection 4.7.Sofirgs and TaskletsSection4.8.WorkQueuesSection 4.9.Returning from Interrupts and ExceptionsChapter5.Kernel SynchronizationSection5.1.HowtheKernel Services RequestsSection5.2..SynchronizationPrimitivesSection 5.3.SynchronizingAccessestoKernel Data StructuresSection5.4.Examplesof RaceConditionPreventionChapter6.Timing MeasurementsSection 6.1. Clock and Timer CircuitsSection6.2..TheLinuxTimekeepingArchitectureSection 6.3.Updatingthe TimeandDateSection6.4.Updating SystemStatisticsSection6.5.SofwareTimersand DelayFunctionsSection 6.6.SystemCalls Related to Timing MeasurementsChapter7.Process SchedulingSection 7.1. Scheduling PolicySection 7.2.The Scheduling AlgorithmSection 7.3.Data Structures Used by the SchedulerSection7.4.FunctionsUsedbytheSchedulerSection7.5.RunqueueBalancing inMultiprocessorSystemsSection 7.6.System Calls Related to SchedulingChapter8.Memory ManagementSection 8.1.PageFrame ManagementSection 8.2. Memory Area ManagementSection8.3.NoncontiguousMemoryAreaManagementChapter9.ProcessAddressSpaceSection9.1.TheProcess'sAddress SpaceSection 9.2.The Memory DescriptorSection 9.3.Memory RegionsSection9.4.PageFault Exception HandlerSection9.5.Creating and Deleting a ProcessAddress SpaceSection 9.6.Managing the HeapChapter10.SystemCallsSection 10.1.POSIXAPls and System CallsSection10.2.SystemCall Handlerand ServiceRoutinesSection10.3.EnteringandExitingaSystemCall5
5 Section 4.6. Interrupt Handling Section 4.7. Softirqs and Tasklets Section 4.8. Work Queues Section 4.9. Returning from Interrupts and Exceptions Chapter 5. Kernel Synchronization Section 5.1. How the Kernel Services Requests Section 5.2. Synchronization Primitives Section 5.3. Synchronizing Accesses to Kernel Data Structures Section 5.4. Examples of Race Condition Prevention Chapter 6. Timing Measurements Section 6.1. Clock and Timer Circuits Section 6.2. The Linux Timekeeping Architecture Section 6.3. Updating the Time and Date Section 6.4. Updating System Statistics Section 6.5. Software Timers and Delay Functions Section 6.6. System Calls Related to Timing Measurements Chapter 7. Process Scheduling Section 7.1. Scheduling Policy Section 7.2. The Scheduling Algorithm Section 7.3. Data Structures Used by the Scheduler Section 7.4. Functions Used by the Scheduler Section 7.5. Runqueue Balancing in Multiprocessor Systems Section 7.6. System Calls Related to Scheduling Chapter 8. Memory Management Section 8.1. Page Frame Management Section 8.2. Memory Area Management Section 8.3. Noncontiguous Memory Area Management Chapter 9. Process Address Space Section 9.1. The Process's Address Space Section 9.2. The Memory Descriptor Section 9.3. Memory Regions Section 9.4. Page Fault Exception Handler Section 9.5. Creating and Deleting a Process Address Space Section 9.6. Managing the Heap Chapter 10. System Calls Section 10.1. POSIX APIs and System Calls Section 10.2. System Call Handler and Service Routines Section 10.3. Entering and Exiting a System Call