Creation and description of the process

Source: Internet
Author: User

A Review last week's content

Last week I learned about the process of system calls in Linux, which is the approximate process of system invocation:

A Some basic concepts about process scheduling

fork (): a process is a program of execution and a generic term for the associated resources, and the process begins to survive when it is created, in a Linux system. This is usually the result of calling the fork () system called by copying an existing process to create a completely new process that calls the fork () process as the parent process, the newly generated process is called the subprocess, and at the end of the call, at the same location as the return point, the parent process resumes execution, and the child process begins execution. The fork () system returns two times from the kernel: one return to the parent process, and another to the new child process. where fork () is actually implemented by the clone () system call.

exec (): The new process is executed immediately after the new city is created, and then the EXEC () function is called to create a new address space and load the new address space into it.

Process Descriptor: The kernel holds the list of processes in a two-way loop list called the task queue, the type in the linked list is task_struct, the process descriptor structure, and the process descriptor contains all the information for a specific process. Can fully describe an executing program: The file It opens, the address space of the process, the pending signal, the status of the process, and more.

Thread_info : The task_struct of each process stored at the end of the kernel stack,

Process state transitions:

-whether the task_running is ready or executed depends on the current resource allocation of the system;

-Task_zombie also known as Zombie process

Three. The experimental process

1. Update the menu kernel, then delete test_fork.c and test.c (to reduce the effect on subsequent experiments)

2. Compile the kernel, you can see the fork command

3. Start GDB Debugging and set breakpoints on the main function

4. Fork in Menuos, you will find that the fork function is parked in the parent process

5. After continuing the execution, stop at the do_fork position. Then n steps into Copy_process, Dup_task_struct. Press S to enter the function, you can see DST = src (that is, the struct that replicates the parent process)

6. In Copy_thread, you can see that the Task_pg_regs (p) is the kernel stack-specific address found and initialized

7. The code in line 159 and 160 is the code that puts the pressed into the sub-process:

*children = *current_pt_regs (); Childregs0;

8.164 lines, is the return address is OK

long) Ret_from_fork;

Experimental thoughts:

Just the first time I completed the blog so early, in the course of the experiment, I learned the basic method of inter-process scheduling, but also the implementation of GDB's kernel code debugging, very meaningful.

Creation and description of the process

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.