Linux Learning Summary

Source: Internet
Author: User

Linux Learning Summary

20135103 Allan H.N. Wang

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

First, learning feelings

Nine weeks of study time is over, really to Linux is love and hate, love it's changeable application strong, hate its elusive operation is not easy. Linux is different from the other things learned, holding a book dead chew one months will not have any progress, in addition to their own hands-on practice, but also need a guide to take you in, when you grope to the doorway to follow the road, or may be in circles, or even go astray, it is really an honor to meet Meng teacher, Lead me to the gates of Linux, let me explore, go forward. Meng Teacher's explanation is really good, one hours a week of video, even if that is not an experiment, to later, almost every time to spend three hours to understand it, do not work really catch up, here again to thank Meng Teacher's teachings, and NetEase cloud Classroom provides a free learning to learn about Linux opportunities, Meng teacher hard, your hard not in vain, the students are very respectful of you, thank you, thanks for your guidance.

In addition to the knowledge, there is one thing I am very touched that Linux itself does not have a purpose, he does not have an accurate goal to say what my task is, he is a kernel, and many developers from different places to come from things, these messy things together to become a large wealth, He doesn't say what I do, what I don't do, his existence is for the convenience of all, use it to do all the things you can.

In addition to the public class NetEase cloud, we also follow their own teacher class, learned that Linux is open source, is a kind of sharing, you can find anything you want from the site, this is not for freedom, but to let everyone find what they need, to change, to customize their own code, to the convenience of people.

The biggest advantage of Linux is that it treats all as files, so the biggest benefit is ease of management, although the application of some inconvenience, but this is a very good idea.

Second, weekly focus

First week: Disassembly

As the name implies, is the assembly language into computer language, from the perspective of the CPU is mainly stack and out of the stack, the data into the stack for storage, operation and output, with over EBP,ESP control register changes

Second week: Streamlined kernel analysis (based on time slice rotation)

Here we understand the three magic of the computer: (1) the Storage program computer (2) function call stack (3) Interrupt mechanism

Third week: Tracking the boot process of the analysis kernel

Rest_init () is the start_kernel from the process kernel when the start of the time will always exist, that is, the process of No. No. 0;

Process No. 0 creates kernel threads for process 1th and some other services, so the entire system starts up.

Week Four: System calls

System calls three layer skins: (1) XYZ (API) (2) System_call (Interrupt vector) (3) SYS_XYZ (service program)

Week Five: System_call process analysis

(1) int 0x80 enters the kernel state from the user state and jumps to the System_call () function to execute the corresponding service process. In this process, the kernel first saves the interrupt environment and then executes the system call function.
(2) the System_call () function finds the system call table sys_cal_table through the system call number to find the specific system call service process.
(3) After the system call is executed, the kernel checks for new interrupts, whether a process switch is required, whether to handle signals sent by other processes, etc. before iret.
(4) The kernel is a set of interrupts that handle various system calls, and the process context is switched through the interrupt mechanism, which manages the entire computer hardware and software resources through the system call.
(5) If there are no new interrupts, restore saves the interrupt environment and returns the user state to complete a system call procedure.

Week Six: Process creation process Learning

(1) regardless of which of the three systems call clone, fork, vfork to create a new process, are implemented by calling Do_fork (2) Create a new process (3) child process by copying the task_struct of the parent process PCB             Modify the copied PCB, such as PID, process list, etc. (4) fork () The resulting sub-process from the system call starts at Ret_from_fork, P->thread.ip = (unsigned long) ret_from_fork (5) The return value can be used to determine whether the current process is a parent or child process, the parent process returns the process number, and the child process returns 0 for seven weeks: executable file loading and running

How the executable program is derived: C code is compiled by the compiler, compiled into assembly code, compiled by the compiler into the target code, linked to an executable file

Linux kernel mounts and launches an executable program

(1) Create a new process

(2) The new process calls the EXECVE () system call to execute the specified elf file

(3) Call the kernel's entry function Sys_execve (), SYS_EXECVE () service routines Modify the execution context of the current process

There are 3 main executables in the elf format: relocatable files. o, executable file, share destination file

The elf executable is mapped to the 0x8048000 address by default.

How command-line arguments and environment variables are entered into the new program's stack

The shell program-->execve-->sys_execve and then copies it when the new program stack is initialized.

Function call parameter pass, then system call parameter Pass

The current program executes into the kernel state when the EXECVE system is called, loads the executable file in the kernel with EXECVE, overwrites the executable file of the current process, and execve the system call back to the starting point of the new executable program

The loading process of a dynamic link library is a graph traversal process, in which the. Interp and. Dynamic in the ELF format need to rely on the dynamic linker to parse, and return to the program entry of the dynamic linker when entry returns to the user state instead of returning to the starting point specified by the executable program

Week Eighth: Process scheduling Process Analysis

The general steps for process switching in Linux are: (1) Detecting the status of the current process, suspending the IO request of the current process to prevent deadlocks (2) Getting the current running CPU, and its running process queue (3) to fetch the current process from the process queue and task_struct Scheduling algorithm selects an appropriate process from the queue as a pending incoming process (4) detects the status of the pending incoming process to ensure its correctness (5) Use the SWITCH_TO macro to switch between the current process and the pending process (the resource preparation for completing the new process) (6) The new process is complete sche Dule () to end the entire process switching process

Iii. Summary of Blogs

First week: http://www.cnblogs.com/haiye/p/5213800.html

Second week: http://www.cnblogs.com/haiye/p/5245593.html

Third week: http://www.cnblogs.com/haiye/p/5271563.html

Week Four: http://www.cnblogs.com/haiye/p/5296174.html

Week Five: http://www.cnblogs.com/haiye/p/5325347.html

Week Six: http://www.cnblogs.com/haiye/p/5350333.html

Seventh Week: http://www.cnblogs.com/haiye/p/5374272.html

Eighth Week: http://www.cnblogs.com/haiye/p/5402162.html

Iv. Summary

To tell the truth, is not a compliment, this course regrets that time is too short, a lot of things can not continue to learn, if Meng teacher can go on to talk about the good, really can learn a lot of things. Some things learn is not just a discipline, more important is the teacher's thinking, knowledge if only learn, and can not digest, I think and did not learn the difference is not small, sketchy than hard plug knowledge, really good much too much, only logic to make clear, the main line to understand, the mind of the Organization will be clear, So that I can really say that I have studied this course.

Although this course in NetEase Cloud School is finished, but my course is not over, thank Meng teacher took me in the door, take me through the beginning of the ignorant stage, then I will go on their own serious. More Chemeng teacher, hard.

Linux Learning Summary

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.