Analyzing the process of creating a new process for the Linux kernel

Source: Internet
Author: User


Analyzing the process of creating a new process for the Linux kernel

Shahuzy

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

First, the purpose of the experiment

Read and understand task_struct data structure; Analyze the kernel processing process of the fork function Sys_clone, understand how to create a new process and how to create and modify task_struct data structures; use GDB trace to analyze a fork system to call the kernel processing function sys_ Clone, which validates the understanding of the Linux system creation, and where the process begins to execute.

Ii. contents of the experiment

First, enter the lab building environment and enter the Linuekernel file.


Then, delete Menu,clone a new one, and then overwrite the test.c with Fork.c,makerootfs.


Enter Menuos to realize the function of fork function.

Please come to size S, set breakpoints: Sys_clone,do_fork, Dup_task_struct, Copy_process,copy_thread. (Sorry, really good card, set breakpoints where the location is not met, the principle of the previous experiment.) )

Trace Analysis a fork system calls the kernel handler function Sys_clone, ending the experiment.

Iii. Summary of the experiment (including analysis)

TASK_STRUCT database structure is very large, the state of Linux process and operating system principle described in the process state is different, such as the ready state and running state are task_running. A brief two-way loop linked list. A process created by a program has a parent-child relationship

The system calls the kernel handler function Sys_clone creates a new process by calling Do_fork to create the process, and Linux creates the process by replicating the parent process's PCB, and then modifies it accordingly.

The child process is returned in the kernel, executed in the kernel, and when the child process starts running, its ret_from_fork will do a series of work and then return to the user state.

Through the study of this chapter, I have a certain understanding of the task_struct, and understand the process of the creation of the specific process.

Analyzing the process of creating a new process for the Linux kernel

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.