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.