中国高校课件下载中心 》 教学资源 》 大学文库

《ARM技术及其应用》课程教学资源(文献资料)Linux Kernel Development 3rd Edition - 2010

文档信息
资源类别:文库
文档格式:PDF
文档页数:468
文件大小:4.29MB
团购合买:点击进入团购
内容简介
《ARM技术及其应用》课程教学资源(文献资料)Linux Kernel Development 3rd Edition - 2010
刷新页面文档预览

Third EditionRobert LoveLinux KernelDevelopmentA thorough guide to the design andimplementationof the LinuxkernelDeveloper's LibraryWebooknto

www.it-ebooks.info

Linux KernelDevelopmentThird Editionwww.it-ebooks.info

ptg Linux Kernel Development Third Edition www.it-ebooks.info

Developer's LibraryESSENTIALREFERENCESFORPROGRAMMINGPROFESSIONALSDeveloper's Library books are designed to provide practicing programmers withunique, high-quality references and tutorials on the programming languages andtechnologies they use in their daily work.All books in the Developer's Library are written by expert technology practitionerswho are especially skilled at organizing and presenting information in a way thatsuseful for other programmers.Key titles include some of the best, most widely acclaimed books within theirtopic areas:PHP&MySQLWebDevelopmentPython Essential ReferenceDavid BeazleyLuke Welling & Laura ThomsonISBN-13: 978-0-672-32978-6ISBN 978-0-672-32916-6MySQLProgramming in Objective-C 2.0Paul DuBoisStephen G. KochanISBN-13: 978-0-672-32938-8ISBN-13:978-0-321-56615-7Linux Kernel DevelopmentPostgreSQLRobert LoveKorryDouglasISBN-13: 978-0-672-32946-3ISBN-13:978-0-672-33015-5Developer's Library books are available at most retail and online bookstores, as wellas by subscription from Safari Books Onlineat safari.informit.comDeveloper'sLibraryinformit.com/devlibrarywww.it-ebooks.info

ptg informit.com/devlibrary Developer’s Library ESSENTIAL REFERENCES FOR PROGRAMMING PROFESSIONALS Developer’s Library books are designed to provide practicing programmers with unique, high-quality references and tutorials on the programming languages and technologies they use in their daily work. All books in the Developer’s Library are written by expert technology practitioners who are especially skilled at organizing and presenting information in a way that’s useful for other programmers. Key titles include some of the best, most widely acclaimed books within their topic areas: PHP & MySQL Web Development Luke Welling & Laura Thomson ISBN 978-0-672-32916-6 MySQL Paul DuBois ISBN-13: 978-0-672-32938-8 Linux Kernel Development Robert Love ISBN-13: 978-0-672-32946-3 Python Essential Reference David Beazley ISBN-13: 978-0-672-32978-6 Programming in Objective-C 2.0 Stephen G. Kochan ISBN-13: 978-0-321-56615-7 PostgreSQL Korry Douglas ISBN-13: 978-0-672-33015-5 Developer’s Library books are available at most retail and online bookstores, as well as by subscription from Safari Books Online at safari.informit.com Developer’s Library www.it-ebooks.info

Linux KernelDevelopmentThird EditionRobertLoveAddison-WesleyUpperSaddleRiver, NJ.Boston·Indianapolis·SanFranciscoNew York·Toronto·Montreal.London·MunichParis·MadridCapeTown·Sydney·Tokyo·Singapore·MexicoCitywww.it-ebooks.info

ptg Linux Kernel Development Third Edition Robert Love Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Cape Town • Sydney • Tokyo • Singapore • Mexico City www.it-ebooks.info

Acquisitions EditorLinuxKernelDevelopmentMarkTaberThird EditionDevelopmentCopyright2010PearsonEducation,IncEditorMichael ThurstonAll rights reserved.Printed in the United Statesof America.Thispublication isprotected bycopyright, and permission must be obtained from the publisher prior to any prohibited repro-Technical Editorduction,storage in a retrieval system,ortransmission inanyformorby anymeans,elecRobert PJ.Daytronic,mechanical,photocopying,recording,orlikewise.Managing EditorISBN-13: 978-0-672-32946-3Sandra SchroederISBN-10:0-672-32946-8Senior ProjectEditorLibraryof Congress Cataloging-in-PublicationData:TonyaSimpsonLove, Robert.Copy EditorLinuxkerneldevelopment/RobertLove.3rded.Apostrophe EditingServicesp. cm.IndexerIncludesbibliographical references and indexBrad HerrimanISBN978-0-672-32946-3(pbk.:alk.paper)1.Linux.2.Operating systems(Computers)Proofreader1. Title.DebbieWilliamsPublishingQA76.76.063L6742010Coordinator005.4'32—dc22Vanessa Evans2010018961Book DesignerGary AdairText printed in the United States on recycled paper at RR Donnelley, Crawfordsville, Indiana.CompositorFirstprintingJune2010Mark ShirarMany of the designations used by manufacturers and sellers to distinguish their productsareclaimedastrademarks.Wherethosedesignationsappearinthisbook,andthepublisherwas aware ofatrademarkclaim,thedesignations havebeenprintedwith initialcapitallettersorinallcapitals.Theauthorandpublisherhavetakencareinthepreparationofthisbook,butmakencexpressedorimpliedwarrantyofanykindandassumenoresponsibilityforerrorsoromis-sions.No liabilityisassumedfor incidental orconsequentialdamages in connection withorarising out of the use of the information or programs contained herein.Thepublisheroffersexcellentdiscountsonthisbookwhenorderedinquantityforbulkpur-chasesorspecialsales,whichmayincludeelectronicversionsand/orcustomcoversandcontentparticularto yourbusiness,traininggoals,marketing focus,and branding interests.Formoreinformation,pleasecontact:U.S.CorporateandGovernmentSales(800)382-3419corpsales@pearsontechgroup.comForsalesoutsidetheUnited Statesplease contact:InternationalSalesinternational@pearson.comVisitusontheWeb:informit.com/awwww.it-ebooks.info

ptg Linux Kernel Development Third Edition Copyright © 2010 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited repro￾duction, storage in a retrieval system, or transmission in any form or by any means, elec￾tronic, mechanical, photocopying, recording, or likewise. ISBN-13: 978-0-672-32946-3 ISBN-10: 0-672-32946-8 Library of Congress Cataloging-in-Publication Data: Love, Robert. Linux kernel development / Robert Love. — 3rd ed. p. cm. Includes bibliographical references and index. ISBN 978-0-672-32946-3 (pbk. : alk. paper) 1. Linux. 2. Operating systems (Computers) I. Title. QA76.76.O63L674 2010 005.4’32—dc22 2010018961 Text printed in the United States on recycled paper at RR Donnelley, Crawfordsville, Indiana. First printing June 2010 Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publish￾er was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omis￾sions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk pur￾chases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States please contact: International Sales international@pearson.com Visit us on the Web: informit.com/aw Acquisitions Editor Mark Taber Development Editor Michael Thurston Technical Editor Robert P. J. Day Managing Editor Sandra Schroeder Senior Project Editor Tonya Simpson Copy Editor Apostrophe Editing Services Indexer Brad Herriman Proofreader Debbie Williams Publishing Coordinator Vanessa Evans Book Designer Gary Adair Compositor Mark Shirar www.it-ebooks.info

4For Doris and Helen.www.it-ebooks.info

ptg ❖ For Doris and Helen. ❖ www.it-ebooks.info

Contents at a Glance1 Introductionto the Linux Kernel12 GettingStarted with theKernel 113ProcessManagement234 ProcessScheduling415SystemCalls696 Kernel Data Structures857 Interrupts and Interrupt Handlers1138 BottomHalvesandDeferringWork1339 AnIntroductiontoKernelSynchronization1611o KernelSynchronizationMethods17511 TimersandTimeManagement20712MemoryManagement23113TheVirtualFilesystem26114 The Block /0 Layer28915TheProcessAddressSpace:30516ThePageCacheandPageWriteback32317 Devices andModules633718Debugging36319Portability3792oPatches,Hacking,andtheCommunity395Bibliography407Index411www.it-ebooks.info

ptg Contents at a Glance 1 Introduction to the Linux Kernel 1 2 Getting Started with the Kernel 11 3 Process Management 23 4 Process Scheduling 41 5 System Calls 69 6 Kernel Data Structures 85 7 Interrupts and Interrupt Handlers 113 8 Bottom Halves and Deferring Work 133 9 An Introduction to Kernel Synchronization 161 10 Kernel Synchronization Methods 175 11 Timers and Time Management 207 12 Memory Management 231 13 The Virtual Filesystem 261 14 The Block I/O Layer 289 15 The Process Address Space 305 16 The Page Cache and Page Writeback 323 17 Devices and Modules 337 18 Debugging 363 19 Portability 379 20 Patches, Hacking, and the Community 395 Bibliography 407 Index 411 www.it-ebooks.info

Table of Contents1 Introduction to the Linux Kernel1History of Unix1AlongCameLinus:Introductionto Linux3OverviewofOperatingSystemsandKernels4.LinuxVersus ClassicUnixKernels6LinuxKernel Versions8TheLinuxKernelDevelopmentCommunity10BeforeWe Begin10112Getting Started withtheKernel11ObtainingtheKernelSourceUsing Git11Installing theKernel Source12UsingPatches12TheKernel SourceTree12Building the Kernel 13Configuring the Kernel1415Minimizing Build NoiseSpawningMultipleBuild JobsS1616InstallingtheNewKernel16ABeastof aDifferentNatureNo libcorStandardHeaders17GNUC18InlineFunctions61819InlineAssemblyBranchAnnotation19NoMemoryProtection20No (Easy) Use of Floating Point20Small,Fixed-SizeStack2021Synchronization and Concurrency21ImportanceofPortabilityConclusion 21www.it-ebooks.info

ptg Table of Contents 1 Introduction to the Linux Kernel 1 History of Unix 1 Along Came Linus: Introduction to Linux 3 Overview of Operating Systems and Kernels 4 Linux Versus Classic Unix Kernels 6 Linux Kernel Versions 8 The Linux Kernel Development Community 10 Before We Begin 10 2 Getting Started with the Kernel 11 Obtaining the Kernel Source 11 Using Git 11 Installing the Kernel Source 12 Using Patches 12 The Kernel Source Tree 12 Building the Kernel 13 Configuring the Kernel 14 Minimizing Build Noise 15 Spawning Multiple Build Jobs 16 Installing the New Kernel 16 A Beast of a Different Nature 16 No libc or Standard Headers 17 GNU C 18 Inline Functions 18 Inline Assembly 19 Branch Annotation 19 No Memory Protection 20 No (Easy) Use of Floating Point 20 Small, Fixed-Size Stack 20 Synchronization and Concurrency 21 Importance of Portability 21 Conclusion 21 www.it-ebooks.info

Contentsvili3ProcessManagement23TheProcess23Process Descriptorandthe Task Structure24AllocatingtheProcessDescriptor:25Storing theProcess Descriptor26Process State27Manipulatingthe Current Process State29ProcessContext29TheProcessFamilyTree29Process Creation3131Copy-on-WriteForking32vfork()33The Linux ImplementationofThreads33Creating Threads34KernelThreads35ProcessTermination36RemovingtheProcessDescriptor37TheDilemma oftheParentless Task38Conclusion40ProcessScheduling41441MultitaskingLinux'sProcessScheduler42Policy43I/O-Bound VersusProcessor-BoundProcesses643ProcessPriority44Timeslice4545TheSchedulingPolicyinAction46The LinuxSchedulingAlgorithm46SchedulerClasses47Process Scheduling inUnix SystemsFair Scheduling4850TheLinuxSchedulingImplementationTime Accounting 5050TheScheduler Entity StructureTheVirtual Runtime51www.it-ebooks.info

ptg viii Contents 3 Process Management 23 The Process 23 Process Descriptor and the Task Structure 24 Allocating the Process Descriptor 25 Storing the Process Descriptor 26 Process State 27 Manipulating the Current Process State 29 Process Context 29 The Process Family Tree 29 Process Creation 31 Copy-on-Write 31 Forking 32 vfork() 33 The Linux Implementation of Threads 33 Creating Threads 34 Kernel Threads 35 Process Termination 36 Removing the Process Descriptor 37 The Dilemma of the Parentless Task 38 Conclusion 40 4 Process Scheduling 41 Multitasking 41 Linux’s Process Scheduler 42 Policy 43 I/O-Bound Versus Processor-Bound Processes 43 Process Priority 44 Timeslice 45 The Scheduling Policy in Action 45 The Linux Scheduling Algorithm 46 Scheduler Classes 46 Process Scheduling in Unix Systems 47 Fair Scheduling 48 The Linux Scheduling Implementation 50 Time Accounting 50 The Scheduler Entity Structure 50 The Virtual Runtime 51 www.it-ebooks.info

ContentsixProcessSelection52PickingtheNextTask53AddingProcessestotheTree54RemovingProcessesfromtheTree56TheSchedulerEntryPoint57SleepingandWakingUp58Wait Queues58Waking Up61PreemptionandContextSwitching62UserPreemption62KernelPreemption 63Real-Time SchedulingPolicies64Scheduler-RelatedSystemCalls65Scheduling Policy and Priority-RelatedSystemCalls66ProcessorAffinitySystemCalls6666YieldingProcessorTimeConclusion675SystemCalls69CommunicatingwiththeKernel6970APIs,POSIX,and theC LibrarySyscalls71672SystemCall NumbersSystemCall Performance72System Call Handler73DenotingtheCorrectSystemCall73ParameterPassing74SystemCall Implementation74ImplementingSystemCalls74Verifying theParameters75System Call Context78Final StepsinBindingaSystemCall7981AccessingtheSystemCallfromUser-SpaceWhyNottoImplementaSystemCall82Conclusion83www.it-ebooks.info

ptg Contents ix Process Selection 52 Picking the Next Task 53 Adding Processes to the Tree 54 Removing Processes from the Tree 56 The Scheduler Entry Point 57 Sleeping and Waking Up 58 Wait Queues 58 Waking Up 61 Preemption and Context Switching 62 User Preemption 62 Kernel Preemption 63 Real-Time Scheduling Policies 64 Scheduler-Related System Calls 65 Scheduling Policy and Priority-Related System Calls 66 Processor Affinity System Calls 66 Yielding Processor Time 66 Conclusion 67 5 System Calls 69 Communicating with the Kernel 69 APIs, POSIX, and the C Library 70 Syscalls 71 System Call Numbers 72 System Call Performance 72 System Call Handler 73 Denoting the Correct System Call 73 Parameter Passing 74 System Call Implementation 74 Implementing System Calls 74 Verifying the Parameters 75 System Call Context 78 Final Steps in Binding a System Call 79 Accessing the System Call from User-Space 81 Why Not to Implement a System Call 82 Conclusion 83 www.it-ebooks.info

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档