The system allows a process to create a new process. A new process is a sub-process. A sub-process can also create a new sub-process to form a process tree structure model. All processes in the Linux system are also in a tree structure. The root is automatically constructed by the system, that is, the No. 0 process executed in the kernel state. It is the ancestor of all processes. Process 1 (kernel state) is created by process 0. Process 1 is responsible for Kernel initialization and system configuration, create several kernel threads for high-speed cache and virtual master memory management. Subsequently, process 1 calls execve () to run executableProgramInit, and evolved into the user State process 1, that is, the INIT process. It completes system startup according to the requirements of the configuration file/etc/initab, and creates several terminal registration processes (Getty) numbered 1 and 2.
Each Getty process sets its process group ID and monitors the interface lines configured to the system terminal. When the connection signal from the terminal is detected, the Getty process runs the registration program login through the execve () function. In this case, the user can enter the registration name and password to log on. If yes, the login program then executes the shell through the execv () function. The shell process receives the PID of the Getty process, replacing the original Getty process. Other processes are directly or indirectly generated by shell.
The preceding process can be described as follows: process 0-> kernel process 1-> User process 1 (INIT process)-> Getty process-> Shell Process
Note: As mentioned in the preceding process description, kernel 1 processes call and execute init and evolve to user-state process 1 (INIT process). The former is a function and the latter is a process. The two are easy to confuse, with the following differences:
1. The init () function runs in the kernel state, which is the kernelCode
2. The INIT process is the first user process started and run by the kernel and runs in the user State.
3. kernel 1 processes call execve () to load the executable program init from the file/etc/inittab and execute it. This process does not call do_fork (), so both processes are process 1.
From: http://blog.csdn.net/yjzl1911/article/details/5613569