Init () function in php and init process in linux

Source: Internet
Author: User
In php, The init () function and the linux system init process-general Linux technology-Linux programming and kernel information. The following is a detailed description. Because the kernel thread that executes the init () function and the process identifier of the init process are both 1, and they are also called init, The init () function and the init process are prone to conceptual ambiguity.

Main differences:

1. The init () function is part of the kernel code and runs in the kernel state. It is part of the independent executable code.

2. The init process is a special process in the Linux operating system. It is the first user process started and run by the kernel, so it is not running in the kernel state, instead, it runs in the user State. Its code is not a part of the kernel itself, but is stored in the image of executable files on the hard disk, which is no different from other user processes.

Process 0 --> kernel thread 1 --> kernel process 1 --> init process (user process 1)

Process no. 0: this is a process automatically formed during system boot, which is actually the kernel itself. It is the ancestor of all later processes in the system. After the kernel system completes its own initialization, the kernel itself calls the kernel_thread () function, which uses the int 0x80 system call to create the first kernel thread.

Kernel thread 1: A kernel thread is a process without virtual storage space in Linux. The kernel thread can directly use the physical address space and run in the kernel state. After a Soft Interrupt System Call is returned, the Parent and Child processes are determined by comparing the values of the ESP and ESI registers. If the value of the ESP register is equal to the value of the ESI register, the system considers it as the parent process, namely the kernel itself, and it is the process no. 0. Otherwise, it is the first kernel thread created by the kernel. Therefore, this thread is thread 1.

Kernel process 1: If it is the kernel thread 1, the program controls the subroutine to directly execute the init () function. Then, thread 1 will evolve into the kernel process 1.

Init process: the init () function calls execve () to load and execute the executable program init () from the file/etc/inittab, and then execute init () the kernel process of function 1 has evolved into the init process. That is to say, the init process is generated by the init () function. Fork () is not used in this evolution. Therefore, the process identifier of the init process is still the identifier 1 of kernel process 1.
Related Article

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.