商家名称 | 信用等级 | 购买信息 | 订购本书 |
Linux内核设计与实现(英文版.第3版)(洛夫著) | |||
Linux内核设计与实现(英文版.第3版)(洛夫著) |
《Linux内核设计与实现(英文版·第3版)》:经典图书新版,学习Linux内核最佳读物。
作者:(美国)洛夫(Robert Love)
Robert Love is an open source programmer,speaker,and author who has been usingand contributing to Linux for more than 15 years. Robert is currendy senior softwareengineer at Google,where he was a member of the team that developed the Androidmobile platform's kernel.Prior to Google,he was ChiefArchitect,Linux Desktop,atNoveU.Before NoveU.he was a kernel engineer at MontaVista Software and Xilllian. Robert's kernel projects include the preemptive kernel,the process scheduler,thekernel events layer,inotifi],VM erdaancements,and several device drivers. Robert has given numerous talks on and has written multiple articles about the Linuxkernel.He is a contributing editor for Linux Iournal.His other books include LinuxSystem Programming and Linux in a Nutshell. Robert received a B.A.degree in mathematics and a B.S.degree i11 computer sciencefrom the University ofFlorida.He lives in Boston.
1 Introductlon to the Unux Kernel1
History of Unix1
Along Came Linus:Introduction to Linux3
Overview of Operating Systems and Kernels4
Linux Versus Classic Unix Kernels6
Linux Kernel Versions 8
The Linux KerneI Development Community10
Before We Begin10
2 Getting Started with the Kernel 11
Obtaining the Kernel Source11
UsingGit 11
Installing the Kernel Source12
Using Patches12
The Kernel Source Tree12
Building the Kernel3
Configuring the Kernel14
Minimizing Build Noise15
Spawning Multiple Build Jobs16
Installing the New Kernel16
A Beast ofa Difierent Nature16
No Iibc or Standard Headers17
GNU C18
Inline Functions18
Inline Assembly19
Branch Annotation19
No Memory Protection20
No(Easy)Use of Floating Point20
SmalI.Fixed.Size Stack20
Synchronization and Concurrency21
Importance of Portability21
Conclusion21
3 Process Management23
The Process23
Process Descriptor and the Task Structure24
Allocating the Process Descriptor 25
Storing the Process Descriptor 26
Process State27
Manipulating the Current Process State 29
Process Context29t
The Process Family Tree29
Process Creation31
Copy-on-Write31
Forking 32
vforko33
The Linux Implementation of Threads33
Creating Threads34
KerneI Threads35
Process Termination36
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 AIgorithm 46
Scheduler Classes 46
Process Scheduling in Unix Systems 47
Fair Scheduling 48
The Linux Scheduling Implementation50
Time Accounting50
The Scheduler Entity Structure50
The VirtuaI Runtime51
Process Selection52
Pickingthe NextTask 53
Adding Processes to the Tree54
Removing Processes from the Tree56
The Scheduler Entry Point57
Sleeping and Waking Up58
WaitQueues 58
Waking Up 61
Preemllotion and Context Switching 62
User PreemptionI62
Kernel PreemIption63
Real-Time Scheduling Policies64
ScheduIer.Related System Calls65
Scheduling Policy and Priority-Related
System Calls66
Processor Affinity SystemI Calls66
Yielding Processor Time66
Conclusion67
5 System Calls 69
Communicating with the Kernel69
APIs,POSIX。and the C Library 70
Syscalls71
System Call Numbers72
System CalI Performance72
System Call Handler73
Denoting the Correct System Call73
Parameter Passing74
System Call Implementation74
Implementing System Calls74
Verifying the Parameters75
System CalI Context 78
Final Steps in Binding a System Call79
Accessing the System Call I from Use Space 81
Why Not to Implement a System Call 82
Conclusion 83
6 KerneI Data Structures 85
Linked Lists 85
Singly and Doubly Linked Lists 85
Circular Linked Lists 86
Moving Through a Linked List 87
The Linux Kernel's Implementation 88
The Linked List StFUcture88
Defining a Linked'List 89
List Heads90
Manipulating Linked Lists90
Adding a Node to a Linked List90
Deleting a Node from a Linked List91
Moving and Splicing Linked List Nodes92
Traversing Linked Lists93
The Basic Approach93
The Usable Approach93
Iterating Through a List Backward94
Iterating While Removing95
Other Linked List Methods96
Queues 96
kfIf097
'
Creating a Queue97
Enqueuing Data98
Dequeuing Data98
Obtaining the Size of a Queue98
Resetting and Destroying the Queue99
Example Queue Usage99
Maps100
Initializing an idr101
Allocating a New UlD101
Looking Up a UID102
Removing a UID 103
Destroying an idr103
Binary Trees103
Binary Search 1.rees104
Self-Balancing Binary Search Trees105
Red-Black Trees105
rbtrees106
As the Linux kernel and the applications that use it become more widely used, we areseeing an increasing number of system software developers who wish to become involvedin the development and maintenance of Linux. Some of these engineers are motivatedpurely by personal interest, some work for Linux companies, some work for hardwaremanufacturers, and some are involved with in-house development projects. But all face a common problem: The learning curve for the kernel is getting longerand steeper. The system is becoming increasingly complex, and it is very large. And as theyears pass, the current members of the kernel development team gain deeper and broaderknowledge of the kernel's internals, which widens the gap between them and newcomers. I believe that this declining accessibility of the Linux source base is already a problemfor the quality of the kernel, and it will become more serious over time.Those who carefor Linux clearly have an interest in increasing the number of developers who can con-tribute to the kernel. One approach to this problem is to keep the code clean: sensible interfaces, consistentlayout, "do one thing, do it well," and so on. This is Linus Torvalds' solution. The approach that I counsel is to liberally apply commentary to the code: words thatthe reader can use to understand what the coder intended to achieve at the time. (Theprocess of identifying divergences between the intent and the implementation is knownas debugging. It is hard to do this if the intent is not known.) But even code commentary does not provide the broad-sweep view of what a majorsubsystem is intended to do, and of how its developers set about doing it. This, the start-ing point of understanding, is what the written word serves best. Robert Love's contribution provides a means by which experienced developers cangain that essential view of what services the kernel subsystems are supposed to provide,and of how they set about providing them. This will be sufficient knowledge for manypeople: the curious, the application developers, those who wish to evaluate the kernel'sdesign, and others. But the book is also a stepping stone to take aspiring kernel developers to the nextstage, which is making alterations to the kernel to achieve some defined objective. Iwould encourage aspiring developers to get their hands dirty: The best way to under-stand a part of the kernel is to make changes to it. Making a change forces the developerto a level of understanding which merely reading the code does not provide.
插图:
The Linux Kernel Development Community
When you begin developing code for the Linux kernel,you become a part of the globalkernel development community.The main forum for this community is the Linux KernelMailing List(oft-shortened to lkml).Subscription information is available at http://vger.kernel.org.Note that this is a 11igh-traffic list with hundreds of messages a day and thatthe other readers——who include all the core kernel developers.including Linup-are notopen to dealing with nonsense.The list is,however,a priceless aid during developmentbecause it is where you can find testers,receive peer review,and ask questions. Later chapters provide an overview of the kernel development process and a morecomplete description ofparticipating successfully in the kernel development community.In the meantime,however,lurking on(silently reading)the Linux Kernel Mailing List isas good a supplement to this book as you can find.Before We BeginThis book is about the Linux kernel:its goals,the design that fulfills those goals,and theimplementation that realizes that design.The approach is practical,taking a middle roadbetween theory and practice when explaining how everything works.My objective is togive you an insider's appreciation and understanding for the design and implementationof the Linux kernel.This approach,coupled with some personal anecdotes and tipS onkernel hacking,should ensure that this book gets you off the ground running,whetheryou are looking to develop core kernel code,a new device driver ,or simply better under-stand the Linux operating system. While reading this book,you should have access to a Linux system and the kernelsource.Ideally,by this point,you are a Linux user and have poked and prodded at thesource,but require some help making it all come together.Conversely,you might neverhave used Linux but just want to learn the design of the kernel out of curiosity.However,ifyour desire is to write some code ofyour own,there is no substitute for the source.Thesource code isfreely available;use it! Oh,and abore all else,have fun!
相关阅读:
更多图书资讯可访问读书人图书频道:http://www.reAder8.cn/book/