Linux Kernel Learning Summary (final)

Source: Internet
Author: User

Linux Kernel Learning Summary

Fu Yu Original works reproduced please specify the source

"Linux kernel analysis"MOOC course http://mooc.study.163.com/course/USTC-1000029000

Over the past eight weeks, I have never been able to spell out the word "Linux" to know a lot of proper nouns, but also about how linux Works, a series of advances that have accumulated over the week. Now look back, there is a kind of sunshine after the wind and rain after the feeling, although this metaphor seems inappropriate.

Talk less, then enter this topic.

First, the understanding of the Linux operating system

1, the three main functions of the operating system: process Management (CORE), memory management and file system

2, this picture is Meng teacher video, is a typical Linux operating system Architecture

Bottom: Disk Management, physical memory management, memory controllers and consoles, and more

Previous layer: Management of hardware Resources

Green layer: Implementation of the Kernel (CPU scheduling, memory management, virtual memory, Disk Management, file system, etc.)

One more layer: System call interface

Orange layer: Basic software (Shell, shared library Lib, compiler, dynamic loader, etc.)

Top level: User program

3, The general implementation process of Linux system (from The perspective of the CPU)

In The system of the x86 , a process has an address space of 4G;0 to 3G is User-state, and more than 3G is only accessible by the kernel (for all processes,3G or more of the parts are fully shared).

After being trapped in the kernel state, process X switches to process Y.

The switchover process is as follows:

(1) running user-state process X

(2) An interrupt occurs //The current CPU context is pressed into the kernel stack of the current user-state process X, It then loads information about the kernel stack of the current process (the starting point,Ss:esp , and so on for the service routines that are currently interrupted ). These actions are done automatically by the CPU .

(3)save_all // system invoke macros used to protect the field during processing

(4) schedule ()isinvoked during interrupt processing or before the interrupt is returned , where the switch_to does a critical process context switch // There is always a scheduling time during interrupt processing, scheduling may occur

(5 ) label 1 y ( here y had been switched out through the above steps so that it can be from the label 1 Continue, that's next process once did prev )//< Span style= "font-family: the song Body;" > Here is the user-state process y kernel part

(6)Restore All// recovery site ?

(7)iret //pop The information that the Y process saves to the kernel stack when an interrupt occurs

(8) continue to run user-state process Y

The kernel can actually be likened to a taxi, which process can be stuck into the kernel state, do some work and then return to the user state, the next interruption and can enter the kernel state; When the taxi has no guests, it enters the CPU idle(0 process).

Summary: The kernel is a collection of various interrupt processing processes and kernel threads.

4. Own Understanding

(1) The main thing in the process of the Linux operating system is the process switching, during the process of switching the process will occur interrupt processing, there will be the kernel stack switch, assembly code is the key to understanding. Where the interrupt and interrupt return process has a CPU Context Switch, there is a process context switch during process scheduling, that is, switching from one process's kernel stack to the kernel stack of another process.

In understanding the process switching process, we can use the gdb command to set breakpoints on the kernel code to debug trace, where switch_to,sys_clone, do_fork and so on are all very important functions.

(2) when running a process, the system will first call get from the user state into the kernel state, the various information after the stack, into the system call waiting for keyboard input, at this time it is in a blocking state. during the wait, the CPU may be dispatched to perform other processes, and when there is a keyboard input, I/O interrupts occur, and then the process can be dispatched back to the beginning. When the current process finishes executing, it may enter idleor other processes may be executed.

In the process of waiting for the process, if the keyboard input ls,theCPU will start to execute the interrupt handler, process management will switch to this process, when gets After the system call obtains the data, it returns to the user state, continuing with the following instruction.

II. List of directories for all blog jobs

1, http://www.cnblogs.com/fuyujing/p/5210307.html

2, http://www.cnblogs.com/fuyujing/p/5238627.html

3, http://www.cnblogs.com/fuyujing/p/5260806.html

4, http://www.cnblogs.com/fuyujing/p/5286342.html

5, http://www.cnblogs.com/fuyujing/p/5314258.html

6, http://www.cnblogs.com/fuyujing/p/5336361.html

7, http://www.cnblogs.com/fuyujing/p/5358368.html

8, http://www.cnblogs.com/fuyujing/p/5381660.html

Iii. Summary

After studying this course, my greatest achievement was to learn a new, previously completely without concept of knowledge, the course began to talk about the register of the knowledge point is also equivalent to let me review the things I learned before. And now I can analyze some relatively simple stack changes, understand some simple kernel code, remember some of the Linux Command line interface operation instructions. In general, It is not very strange to hear the term Linux later, because the weekly net lesson is quite impressive.

Linux Kernel Learning Summary (final)

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.