Linux Process 0 and INIT process 1
Process 0: the first process created in Linux boot. After the system is loaded, it becomes a process scheduling, switching, and storage management process.
Process 1: The INIT process, created by the 0 process, initializes the system. It is the ancestor process of all other user processes in the system.
In Linux, process 1 is created by process 0. Therefore, you must know how to create process 0,ProgramThe process has been running in the kernel state, while the process is running in the user State. Therefore, the creation of process 0 involves changes in the privileged level, from the privileged level 0 to the privileged level 3, in Linux, a privileged-level change is realized by simulating the interrupt return and the process 0 is created.CodeSegment Selection Sub-and program counter EIP is directly pushed into the kernel state stack, and then the iret Assembly command is used to interrupt the return to jump to process 0 to run.
The Code is as follows:
Move_to_user_mode (); // create process 0, start to enter process 0, and switch to privileged level 3 for running
If (! Fork () {Init ();} // create process 1
In Linux, what are the consequences of sending a termination signal to the INIT process using the kill function?
The INIT process is a special process that neither receives nor processes signals. There is no result when you send an end signal to it.
The following is the 2.4.0 kernel.Source codeComments in front of the do_signal () function in:
/** Note that 'init 'is a special process: it doesn' t get signals it doesn' t * want to handle. thus you cannot kill init even with a sigkill even by * Mistake. */