The world is sad to end, the Octopus elder brother also retired, even the non-sincerity does not disturb in the worship diggers also suddenly a lot less. This "Linux kernel cultivation of the road" in excellence, when, China-pub has also been on sale, although serious literature, but in order to ensure fluency, most of the text I also are the words of the burning sentence, repeated read several times to write up, as far as possible to consider the writing of each paragraph can let readers produce what doubts, Then it will be explained as soon as possible, and many of the concepts in the middle have repeatedly struggled to explain how to interpret it more easily, and try to read it with little hindrance even for beginners. At the same time I also take part of the book's own sentiment out to organize the essence version, share out. Of course, the level is limited, errors and omissions found in the revision of the omission, there has not yet been found. If this book is useful to you, it is my blessing, if useless, I would like to first of all to worship a No.
In June, a "efficient learning of the Linux kernel" presentation, the following is part of the previous content and handouts, perhaps useful for everyone. As for the rest, because it is similar to some of the articles in the previous blog, it is not posted.
**********************************************************************
Since there is efficiency, the relative is inefficient. Learning itself is a very iffy thing, some people all day Sasa do not see how attentively can get very good results, and some people on the contrary, even if cast cantilever cone biting also is mediocre results. A large part of the reason for this is the way of learning.
But the learning method is not a good topic to say, because based on the different circumstances of each person, and there is no such a standard method exists, so it is easy to talk about a big flicker. Just like our Mr. Ren Zhiqiang's way of selling the house, he was throwing shoes at the audience because it was so much like a bluff.
Then I will pass some of my own sentiment, to introduce how to more efficient to learn the Linux kernel. These words are not confined to a certain part of the content, much like the slogan of a sentence, we can also consider them as kernel learning character posters.
First is the first sentence: the kernel as a friend. This year the teacher laughed to have a new book, called the time as a friend, tell us that only time as a friend, to better use their time to do something useful. In the same way, we can know and understand the essence of the kernel only if we treat it as a friend and put it on the equal footing, not just a bunch of lifeless code.
Then there is the second sentence: it will be used first. It means that we will use Linux first before we learn the kernel, and follow a step-up process from top to bottom, before we can use the Linux operating system skillfully to study the implementation of the kernel. This is also the view of Linus himself.
The third sentence is the kernel learning according to four levels. Descartes on one day in 17th century, idle extremely bored to write such a book, the title is called "Methodology", in this current most people do not know the book will rise to the height of the theory. In his book, Descartes summed up the problem-based approach into a simple sentence: "Complex issues to be simplified." This means that complex problems should be broken down into a number of simple small problems, separated by a separate solution. This sentence of course can learn from the application to the kernel, but need to make some changes, not broken down into a number of simple small problems, but the kernel learning such a complex thing divided into from low to high many different levels, each level has its own needs to achieve the goals and requirements. This is what I think is a better way to learn the kernel.
The forth sentence is out of the psychological misunderstanding. For learning this complex thing, whether it is our classroom study in the school, or the core learning here, its effect is good and bad, the most important depends on two aspects: one is the method of learning, the other is the psychology of learning. Note that here I ignore the difference in IQ, IQ this thing is too mysterious, can be attributed to the category of superstition. And we often in the study of a series of problems or myths, only out of these misunderstandings, in the study to form a strong psychological, we can truly achieve efficiency.
The second sentence is to use vim+cscope+ctags to browse the kernel source. In fact, the main meaning of this sentence is that we need a good tool to browse the kernel code. Under Windows, we may be able to easily find a lot of better IDE can be used to browse the code, such as source insight, it can be easily linked between the code to read. But for Linux newcomers, there is a common problem with a tool that features similar browsing code.
The sixth sentence is to use the kernel map to locate the target code. It should be said that learning the kernel is the kernel of the source code, but the kernel code thousands, and everywhere like a maze, not lost is difficult, and how to face it? At this point we need a map of the kernel to help us locate the target code to be analyzed and to reduce the range and amount of code.
Next is the seventh sentence: analysis of the kernel source code, attitude determines everything. Many of us may have such confusion, but also analyzed the source of a lot of kernel, can always feel that the analysis finished browsing the brain or empty, and did not feel how much harvest. At this point we may be able to see if there is a problem with your attitude when analyzing the code. When we analyze the kernel source code, only follow the rigorous attitude, to understand the implementation of each piece of code, ask more than want to remember, instead of holding a glance, muddle attitude, eventually there will be a great harvest.
The last sentence is: Take the kernel source as the center, persist in learning resources construction. In our core learning process, the kernel source code itself is the best reference material, any other classic or non-classic books is only a complementary role, and should not be replaced by the kernel in our learning process of the dominant position. However, these auxiliary functions can not be neglected, we need to focus on the core source code, adhere to the long-term construction of learning resources is not shaken.
In addition to the eight sentences here, the other may be helpful to everyone's sentiment or method still have a lot.
To be a friend of the kernel is to think of the kernel as a living body, not a bunch of lifeless code.
Specifically, when we learn and browse the implementation of the kernel, we can see it as a real-world mapping. The kernel is written by people in the real world, so whether intentionally or unintentionally, will inevitably contain some of their own real feelings, we can understand the kernel of this context, this hidden in the code behind the philosophy. For example, we can think that the kernel is a big world, a process is a life in this world, process management and scheduling is the power of the Big World, memory is the process of the home, the core of the goal is to make every process of the house has its home.
Since the kernel is supposed to be a living individual, the first thing we know about it is to know some basic information about it, just as we know each other first and foremost through personal basic information.
First from the name, kernel in the dictionary there are two main definitions, one is "soft, a nut edible part", for Linux kernel, of course, the second definition: "The core part of something." So broadly speaking, Linux kernel is the most central part of the Linux operating system, and in the narrow sense, it is just Linus that group of people wrote that bit of code.
Of course, the craved code is quite complex, just from the amount of code, has already broken through the tens. Structurally speaking, it is not long before a person is poor enough to be able to understand all of their own power. So, now emphasize the second sentence: Learn the core should not seek big perfection, choose a little research enough depth is not easy.
The following describes the age of kernel, kernel is not a Huaichun maiden, so its age does not need secrecy, from the birth of 1991, in the last year, just held its own adult ritual, entered a mature development period.
Just as we have our own adolescence, middle-aged, and so on, kernel corresponding also has a lot of different version number, but the difference is that our adolescence is no longer return, kernel different version number is co-existence.
For many years, the kernel version has been allocated in the form of x.y.z 3 numbers, the middle even Y represents the stable version, and the odd y represents the unstable development version. The so-called stable version refers to the kernel features are fixed, the code is stable and reliable, no additional features, to improve is only to modify the code errors. The unstable version refers to the addition of new features to the previous stable version, which is still in development and the code is not running reliably.
For now, the release of the 2.6 kernel has been going on for a long time, so when will the 2.7 be released? Linus My answer is that there will not be 2.7, he will not follow the old model, the new model will be better, not worth repeating the past. He said he was considering a new numbering method, a time-based version number. For example, replace 2.6.26 with 2008.7, the second number in the middle represents the year, 2008 is 2.8, the first version of 2009 is 2.9.1, then 2010 is 3.0, and so on.
Finally I have to mention that the dazzling distribution, the kernel and the distribution of the relationship between the same kind of twins, mutual dependence on each other to support and grow together. Without those distributions, the kernel can only be on the shelf of a seemingly good-looking toys, and can not really walk into our work and life, without the kernel, those distribution is missing the foundation of existence, it can only be a tofu slag project.
Now we understand the core of this friend's appearance, this time we can not be like the non-interference of those who worship diggers only the external information, we also have to understand the kernel of the connotation, that is, the kernel architecture and how the kernel works.
First look at the first diagram, which conveys the message to us that the kernel separates the application from the hardware. The kernel is responsible for interacting with computer hardware, implementing hardware control, scheduling access to hardware resources, and providing a high-level execution environment for user applications and virtual interfaces for accessing hardware.
Hardware compatibility is one of the core design goals, and almost all of the hardware, as long as it is not customized for other operating systems, can be supported by Linux.
Related to hardware compatibility is portability, which is the ability to run Linux on different hardware platforms. This breadth of platform support has been successful, in part because the kernel is clearly partitioned for both system-related and system-independent parts, from the Intel X86 architecture that initially supported only the standard IBM compatible machine to the ability to support almost all hardware platforms such as ARM, MIPS, PowerPC, and so on. So there is the second picture.
The system-independent sections typically define interfaces to the relevant parts of the system, so that the process of porting the kernel to the new architecture becomes the process of confirming the characteristics of those interfaces and implementing them.
At the same time, the connection between the user application and the kernel is usually implemented through the standard C library, which is the middle tier of the kernel, and the standard C library function itself is based on the system invocation provided by the kernel. The user application and some cores are portable through the standard C library and the interface to the system-dependent parts of the kernel system.
So the third picture is more accurate. Among them, the process management part realizes the abstraction of a process world, this process world is similar to our human world, but the individual in our world is human, and in the process world is a process, our people and people through correspondence, mobile phone, network and other traffic, And between processes is a different way of interprocess communication, and we all share the same planet, and all processes share one or more CPUs.
In the world of this process, memory is one of the important resources, just like our land. Therefore, the policy and method of managing memory, that is, memory management is a key factor to determine the performance of the system.
Knowing the architecture of the kernel, let's take a look at how the kernel works.
First, the kernel is used by the system to make the application running on it available. A system call is a bridge between the kernel and the application, compared to open (), close (), read (), write (), the fork () for process operations, wait (), and socket () for network operations, and so on, which provide hardware Abstract, so it is sometimes referred to as a Linux virtual machine.
The obvious abstraction that the kernel provides is the closest real user to the file system, and it's easy to write a program that opens a file and copies its contents to standard output using several system calls such as open (). The kernel provides the user with the "illusion" of a file through these system calls, but in fact it's just a bunch of data with a name, so it's not necessary to negotiate with the hardware's underlying stacks, partitions, and pointers, which is what we often call Abstraction (abstraction), The underlying things are expressed in a more understandable way.
The filesystem is a more obvious abstraction from the kernel, and we can say that it is located in Taiqian, and that there are some behind the scenes, such as process scheduling. On Linux, there may be several processes or programs waiting to run at any one time. The kernel time is scheduled to allocate CPU time to each process, so for a period of time, we have the illusion that the computer runs several programs at the same time.
Another example is the behind-the-scenes memory management, behind the scenes to the point where application developers are not easily aware. Each program runs as if it had its own address space to invoke, and in fact it shares the physical storage of the computer like any other process. Another aspect of memory management is preventing one process from accessing the address space of other processes-a necessary precaution for multi-process operating systems.
Of course, there are other roles behind the scenes, such as the Internet.
Let's take a look at its physical composition now. Earlier versions of the kernel were monolithic, meaning that all parts were statically connected to a large execution file.
Linux kernel (16)-Learn the Linux kernel efficiently