Read the primary concepts that Linuxkernel should possess

Source: Internet
Author: User
The first concept that Linuxkernel should possess-general Linux technology-Linux programming and kernel information. The following is a detailed description. Is Linux kernel a state machine or a structured program process?

The Study of the Operating System demonstrates some correct ideas based on the discussion of Linux kernel.

For the study of Linux kernel, we often hear people refer to the study and analysis of "kernel source code", and the most common research method is "look for a kernel entry point, and follow the flow to do sequential research, but this is a "most of the time wrong" approach.

Because the computer system is a foreground-background system and the Linux kernel is the operating system on this system, the overall kernel behavior is "control patch 」, that is, "transfer of control" and "change of system status" are not "flow" or "structure" problems; recently, a friend asked me about this topic and is also conducting training for the Linux device driver. Therefore, I will sort out this diary to share it with you. If there are any mistakes in the discussion, or you may have different points of view. Please leave a message here.

Many people may have a weak idea about the "Operating System". Specifically, the method for studying the Internal principles of the kernel is as follows:

1. the startup phase of the kernel is discussed from the perspective of "flow.

2. after the kernel is started, the init process will be executed, and the concept of switching to F/B system is that the entire system is a large state machine, the entire system is a series of complex control transfer actions.

Recently, my friend hoped that I could give a brief introduction to the "kernel execution process", but this question should have room for correction or clarification of ideas in the proposition. Because the computer itself is a foreground-background system, the work of foreground will affect which part of the CPU hand over control to the background; if user-space is used as foreground, if the kernel-space is used as the background, the overall system can be expressed as follows.



(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // www.jollen.org/blog/2007/03/24/fb_system.jpg'); ">

The Background is affected by the foreground action. Take the following two processes as an example. Although the execution results are the same, the control path is also set because the actions in foreground are different.

At this time, if we still think about the logic of the "flowchart", of course we cannot understand it? The secret. The difference is that the CPU transfers control to the path of the job system (that is, the Code executed by the kernel. If schedulator is added, the entire control path may be "run the same program at different times. Tricky!

In terms of the research method, incorrect ideas in the proposition will eventually fail to get a correct and perfect conclusion. Therefore, the proposition "we hope to discuss the kernel Execution Process" should be corrected, and give a clearer question. Furthermore, if we cannot recognize that the kernel is a large state machine, we still think about it using the concept of "process and program structure, in addition to a considerable error in the Problem description, you may not be able to figure out how to understand the kernel source code.

As a result, we can see that the entire system must analyze and study its "behavior" after the kernel is started and the init process is executed, rather than wandering in the circle of "structured C program; this concept proves that "viewing code by line" is not the correct method for studying the principle of kernel.

The behavior of the Kernel itself is a series of complex state changes and control transfer, so it is the concept of the state machine. As for the research method, we adopt the concept of process or control path, which part of the source code we want to read. As mentioned above, we have studied the two phases and methods of kernel. When the transition point is init process and the init process is connected, we recommend that you start with the concept of program execution (process creation, to understand the behavior of the entire job system.

Therefore, the study of kernel is based on the analysis and observation of behavior (behavior) in its dynamic (run-time) period.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.