Linux kernel Design period summary Copyright notice: This article for Bo Master original article, without Bo Master permission not reproduced. First eight Weeks blog summary and summary
The first week of Linux kernel design--understanding computer working principle from assembly language
We learned the basics of assembly language, which is not directly related to kernel code, but the teacher specifically takes us through the stack changes in the function call process and how the function passes the arguments during the call. This section is for learning process context switching and interrupting context switching.
Linux kernel Design The second week--how the operating system works
The teacher wrote a simple, small kernel code and led us to read the key code. This paper mainly introduces the My_ schedule function, My_ Start_ kernel function and the interrupt handler My_ time_ function written by yourself. With these three functions, the kernel can be simulated to interrupt the context switching process. Related to this, it also defines the data structure of the MYPCD, and understands the approximate process of process context switching by customizing the process PCB structure.
The third week of Linux kernel design--construct a simple Linux system
The teacher used a simple Linux kernel menuos system to introduce us to the operating system kernel boot process. Learn how to use GDB for kernel debugging, by setting breakpoints at key function locations, stepping through debugging, and gradually analyzing the function of each code. The most important part of the week is to teach us how to learn kernel code through GDB debugging, a capability that is reflected in each of the subsequent chapters.
Linux Kernel Design fourth week--------three layers of skin (top) of the system call
We learned about the system call and understood that the system call is the hub of the communication between the user and the kernel, and it is the link between the two. Second, we understand the system invocation mechanism by writing assembly code. Note that when writing system call code in assembly language, be aware of the difference between the Register pass parameter and the stack pass parameter, do not mix, in the system call, use the Register pass parameter.
Fifth week of Linux kernel design--three layers of peel (bottom)
Week five is based on the fourth week, the assembly code to modify the system call function to add to the menuos, which requires us to modify the kernel code, add new system calls, and learn how to reload, compile and write good code. This week, the teacher focused on how the system calls were returned, that is, how the kernel executes the process from Syscall_ call to Iret, including some specific details.
Linux kernel Design Week sixth--description and creation of the process
Mainly describes the process of description and creation, specific to the process of control block PCB organization, as well as the process to create a design to the data structure, detailed analysis of the composition of the structure of the task_ struct, and the use of its various parts, analysis of the fork system call execution process and return principle, The key process of Do_ fork function execution is analyzed from the Sys_ clone code by emphasizing that the sub-process created by fork is returned by ret_ From_ Fork.
Linux kernel Design Week seventh-executable program loading
This week mainly explained the file format--elf format in Linux system, specific to the origin of the elf format, the elf file format classification, the composition of the specific file header. It also describes how the program executes on the computer, which is done by pre-compiling, compiling, assembling, and linking processes. At the same time, the static loading process and dynamic loading process of executable program are introduced.
Linux kernel Design Week eighth--process switching and general execution of the system
This week mainly revolves around the transition of the process, analyzes the differences and design principles of I/O process scheduling and CPU-intensive process scheduling, introduces the merits of batch process, real-time process and interactive process, and the design of the priority policy of the Linux kernel, and analyzes the differences between user-state process scheduling and kernel-state process scheduling. , the code of the key part of the process context switch is analyzed, including the change of the stack, the process of passing parameters in the kernel stack, analyzing the assembly code, analyzing the interface points of the two process switches from the details, and finally summarizing the general execution process of the Linux system.
Some of my summary and understanding
0, detailed understanding of the blog summary of the weekly summary.
1, the kernel design is for the operating system. The design of the different operating system cores is different.
(Why we study Linux system is because the kernel code of Linux system is open source, we can directly analyze its source code, and Windows system kernel code is private, we are not easy to obtain, however, the core design although there are differences in detail, but the general idea and principle are common).
- 2, the understanding of the Linux operating system.
I think the Linux system works like this:
- First, the NO. 0 process is idle to create its child process 1th process init and 2nd process Kthreadd;
- Number 1th Process Init is the ancestor of all user-state processes, and Init will create new child processes to execute user commands;
- Process Kthreadd # 2nd is the ancestor of all kernel threads.
- In this process, there is a possibility of a conflict, depending on the process priority, or whether the process is an I/O intensive process to determine who first preempted the CPU, which involves a process scheduling policy, and process switching occurs during this process.
- The specifics of process switching involve the preservation and exchange of data between the kernel stack and the user stack, that is, the process context.
- Process is dependent on the existence of the program, which requires reading the file information, by precompiling, compiling, compiling, linking, the generation can not be executed without seeing. Most executables in Linux are in elf format, and the file header information in this format can be used to find the starting point for program execution.
- 2, in the study of "Linux kernel Analysis" course of the biggest harvest?
- The first time to understand the operating system kernel structure and design principles;
- Be impressed by the rigorous logic and ingenious design of the kernel designers;
- Although I can't write a small operating system myself after learning Linux kernel analysis, I learned how to parse kernel code, how to debug kernel code with GDB, and how to understand the implementation of kernel code during debugging.
- It is better to give a man to fish than to give it. I feel that learning this lesson my greatest gain, is to learn the method of kernel code, which is far more important than understanding a kernel design, but also more useful.
- 3. What is your biggest regret after studying the course "Linux kernel analysis"?
My biggest regret is that in the course of the process, the kernel code is not fully understood, but the key code has a certain understanding, I believe that the kernel part of the study is far from the short few weeks to learn the full, I should in the future study, a lot of attention to the design and implementation of the kernel, when necessary, Hands-on practice. In the process of practice, deepen the understanding of the knowledge learned.
Final summary of the Linux kernel analysis