NetEase Cloud Classroom-----Linux Kernel Analysis-----Final subjective questions

Source: Internet
Author: User

Liao + Original works reproduced please specify the source + "Linux kernel analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000

The following is a summary of 8 topics, the title has been edited as a link mode, click to

1. Graphical analysis of assembly code and understanding of how the computer works

Von Neumann architecture of the computer, also known as the storage program computer, from the hardware point of view, its working model is that the CPU reads in-memory instructions in turn to complete the work. This session details how CPU compute modules, registers, and memory work together.

2. Analysis of kernel Code of a simple time-slice rotation multi-channel program based on Mykernel

Mykernel is a kernel platform built by the teacher to open its own operating system, based on the Linux Kernel 3.9.4 source code. Through this talk of learning and experimentation, we know that the core function of the operating system is: process scheduling and interrupt mechanism, through the cooperation with the hardware to achieve multi-tasking, coupled with the support of the upper application software, and eventually become a computer system that can make it easy for users to operate. Also understand the concept of process scheduling and time interruption. Know a process in the kernel, described as a struct, stored the process of PID, running state, stack, and SP and IP and other important information. by analyzing the assembly code of My_schedule, we understand the key process of process switching. We can assume that a process is equivalent to a stack, and each process has its own stack space. If EBP and ESP are modified to the EBP and ESP of another process, and some registers are saved, it is equivalent to switching the completed process.

3. Using GDB to track the Linux kernel boot process

Start_kernel () is the interface between the Assembly of the kernel and the C language, before which the kernel code is written in sinks, completing some of the most basic initialization and environment setup work. Start_kernel is like the main function in C code. Regardless of your focus on Linux kernel modules, you can always leave the Start_kernel function, because most of the initialization work of the module is done in Start_kernel. Follow the experimental steps in this lesson to track the startup process of the Linux kernel. Compile the kernel source code by yourself, and debug the startup process to see what initialization the kernel experienced at startup. almost all of the initialization of the kernel is done in Start_kernel, and before Start_kernel, it is mostly the assembly code that completes some operations. in the Start_kernel, interrupt vectors, memory management modules, scheduling modules, and so on, will initialize a series of initializations. In the final Rest_init (), the No. 0 process and the 1th user-state process are initialized, and then the system is eventually booted.  

4. Use the same system call using the Library function API and the embed assembly code in C code two ways

Even the simplest programs will inevitably use operations such as input, output, and exit, while doing so requires invoking the service provided by the operating system, which is called the system. Unless your program only completes mathematical operations such as subtraction, it is difficult to avoid using system calls. There are two ways to make a system call under the Linux platform: by using the encapsulated C Library (LIBC) or by assembly-direct invocation. This lesson describes the concepts of system invocation and how to use system calls.

5. Analyze the process of system_call interruption

Through GDB we can call the system kernel in the program such as Sys_write, Sys_time set breakpoints, and let the program stop at the breakpoint, the breakpoint tracking system call in the process. Since System_call is a function that is written entirely in sinks, although we can also set breakpoints at System_call, we cannot stop the system at System_call, so we cannot learn the process in a single-step tracking. However, System_call is the entry of all system calls and a function that cannot be crossed when the program is transferred from the user state to the kernel state, so we follow the teacher's simplified assembly code and the source code to learn its main process.

6. Description of the process and creation of the process

To manage the process, the kernel must have a clear description of each process, and the process descriptor provides the process information that the kernel needs to understand. In the development of Linux applications, a sub-process can be created through APIs such as fork, Vfork, and clone, and their corresponding system calls in the Linux kernel are sys_fork, sys_vfork, and Sys_clone functions, respectively. These functions will eventually call Do_fork to complete the creation of the child process. Do_fork primarily replicates the task_struct of the parent process, and then modifies the necessary information to get the task_struct of the child process.

7. How the Linux kernel loads and launches an executable program

The Linux system can start a new process via the Execve API, which also calls the SYS_EXECVE system call, is responsible for replacing the new program code and data into the new process, opening the executable file, loading the dependent library file, requesting a new memory space, and finally executing the Start_ Thread (regs, Elf_entry, bprm->p), set NEW_IP, NEW_SP, complete the new process of code and data substitution, and then return, followed by the execution of the new process code.

8. Process scheduling and process switching process in Linux

The general implementation of the Linux system, the most common situation is: The running user-state process x switch to run the user-state process y process to go through the following steps

1). Running user-state process X

2). Interrupt occurred: Save Cs:eip/esp/eflags (current) to kernel stack, then load CS:EIP (entry of a specific ISR) and Ss:esp (Point to Ke Rnel stack).

3). Save_all//Save site, here is the process that has entered the kernel interrupt

4). Schedule () was called during interrupt processing or before the interrupt was returned, where Switch_to made a critical process context switch

5). After the label 1 begins to run the user-state process y (where Y has been switched out through the above steps so it can continue from label 1)

6). Restore_all//Recovery site

7). Iret-pop Cs:eip/ss:esp/eflags from kernel stack

8). Continue to run user-state process y

Summary: This semester selected the Linux course, the first Class teacher said this lesson to be combined with online learning, although before also heard of online learning, but I have not personally experienced, and the teacher to us introduced a very good platform. For the mixed teaching of flip class, I really and benefit, first of all, we follow the course progress on the Internet to the basic understanding of the course, and after class alone after thinking, then find out their doubts about the place to find teachers to answer questions, so that I can form their own understanding of the curriculum. Through this course, I also learned that MOOC this learning platform, which makes me not only learn Linux, but also give me a learning of their own interest in the course of opportunity, and the MOOC course belongs to the cloud resources, can be cached, which makes the study arrangement is very free. In addition, MOOC provides a good teaching method, every week the task is very clear, and the amount of work is also very appropriate, there is a test every week, you can make their own timely summary and measurement of their content and knowledge of a week, do not know the place can also be posted in the forum, and teachers and classmates to discuss together. There is the experimental building of this network experiment platform, this platform to me we have provided a very large convenience, let us do not have to do experiments at the time also on the computer dedicated to a virtual machine, and can be based on the experimental content of the experimental building environment, targeted strong. I have to say that through the MOOC, the experimental building and the teacher's flip class, I really benefited a lot. When it comes to harvesting, the biggest should be the enhancement of self-learning abilities. As the saying goes, Master leads the door, practicing in the individual. The teacher in this class is playing the role of the guide, and this road is not good to go mainly to see our efforts to practice enough. Through continuous learning, summary, test, let me reap a lot of good learning methods, and in the future of learning life, these experiences can make me faster into the state, less go some detours. Of course, I still have a lot of shortcomings, such as not to the problem of timely feedback, and formed a number of wrong understanding, which for my later study formed a great obstacle. In my view, the ability to raise questions is important, but the ability to solve problems is essential after problems arise. I will apply this sentiment to my life in the future.

NetEase Cloud Classroom-----Linux Kernel Analysis-----Final subjective questions

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.