Understanding of Process Creation in Linux (2)

Source: Internet
Author: User
A process consists of the following elements:
(1) Context of the process
(2) ProgramCurrent execution directory
(3) files and directories of program services
(4) program Access Permissions
(5) memory and other system resources allocated to processes

The most important attributes of a process are the process ID (PID) and the parent process ID (ppid ).
To create a process for a user, use the System Call fork (). The Kernel performs the following operations to complete the system call:
(1) assign a table item to the new process in the progress table.
(2) give the sub-process a unique process tag (PID)
(3) copy the table entry of a parent process to the child process. The sub-process has the same uid, EUID, and GID as the parent process. It is used to calculate the nice value of priority, the current directory, and the description table of the current root and user file.
.
(4) Add 1 to the reference numbers of the file table and index node table connected to the parent process. These files are automatically connected to the sub-process.
(5) The kernel creates user-level context for sub-processes. The kernel allocates memory for the U zone and the secondary page table of the child process, and copies the content of the parent process zone. Generate the static part of the process.
(6) generate the dynamic part of the process. The kernel copies the first layer of the context of the parent process, that is, the register context and kernel stack. This call will return the child process PID to the parent process, and the child process will return 0.

The child process generated by calling fork inherits from the parent process:
Process qualification, environment, stack, memory, open file descriptor, off upon execution, signal control setting, nice value, process scheduling category, process group number, dialog period ID, current working directory, root directory, file mask (umask), resource limit, control terminal.
Resources exclusive to sub-processes include:
Process number, different parent process numbers, file descriptors, and directory stream copies.
 

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.