Linux kernel learning six process creation process learning

Source: Internet
Author: User

A supplement to the Linux process concept

The basic concept of the process there is not much to say here, to add some of your own study income:

1. In the Linux kernel, the system can have a maximum of 64 processes at the same time.

The 2.linux process contains key elements: an executable program, a dedicated system stack space, its control block (Process Control block) in the kernel, and a separate storage space.

3. The first process of the system is generated by a system initialization.

4. The kernel identifies each process through a unique process identification number PID.

5. Data structure Task_struct represents a process, including the properties and state of a process. A pointer to a pre-and post-process in the TASK_STRUCT structure forms a task array.

6. When a new process is generated, Linux assigns a TASK_STRUCT structure to the new process, and then saves the pointer in the task array.

Two commissioning

on the basis of the previous experiment, add the following code:

Running the results in Menuos, you can see that the fork command was added:

To set breakpoints:

The program stops at the first breakpoint:

Simulator Display:

To continue running, the program stops at the second breakpoint:

Simulator Display:

Then run and stop at the third breakpoint:

A fourth breakpoint:

The final result, as shown in the second picture above, is not repeated. The command line in the Menuos input fork, not immediately display the results, in gdb after multiple input "C", the output of PID information.

Three-Analysis Summary

First, attach a flowchart of your own understanding:

Own understanding of:

First the user space application executes the system call to create the process fork (), Vfork (), Clone (), and then switches to kernel space (the process is visible to the previous blog), for the creation process, the kernel is executed do_fork (), in Do_fork () The function calls the function copy_process (), which creates the process descriptor and other data structures required by the child process execution, initially replicating the information of the parent process, such as the stack. But where does the child process start? From the analysis code (P->THREAD.IP = (unsigned long) ret_from_fork;), the child process starts at the RET_FROM_FORK flag and executes ret_from_fork at the end of the Syscall_ Exit, in conjunction with the last learning, identifies the process of returning from kernel space to kernel space. This completes the fork () process for creating the process. (details are yet to be learned ...) )

By: Fanglongwei

Original works reproduced please indicate the source

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

Linux kernel learning six process creation process learning

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.