System Process zygote (1) -- Overview, zygote Overview
The gentle spring light is filled with a pond full of flowers and trees. Let's say goodbye to the lonely dream, come and touch me for a while, and fold a sea bread. -- Xu Zhimo wake up! Wake up!
Ilocker: Follow Android Security (New entry, 0 basics) QQ: 2597294287
First look at a figure (android boot sequence, the source is unknown ):
The underlying layer of android is linux kernel, which is loaded by bootloader. After the kernel is started, start the init process, and then start other processes required by the system, including the zygote process.
Processes started by init are described in the "system \ core \ rootdir \ root. rc" script:
Let's take a look at zygote. rc (taking init. zygote32.rc as an example ):
This script requires the init process to create a process named zygote. The program to be executed by this process is "/system/bin/app_process ". And create a socket resource for the zygote process (for inter-process communication, ActivityManagerService requests the zygote process to fork an application process through this socket ).
During initialization, the zygote process starts the Virtual Machine and loads some system resources. In this way, after zygote fork goes out of the sub-process, the sub-process also inherits the Virtual Machine and various system resources that can work normally. Then, you only need to load the bytecode of the apk file to run the application, it can greatly shorten the application startup time, which is the main role of the zygote process.
Java applications cannot run in the form of local processes. They must run in an independent virtual machine. If you restart the virtual machine every time, the startup speed of the application will be severely slowed down.
Linux processes are all fork-based. The fork-based sub-processes share the memory image with the parent process. The operating system allocates a new page for a child process to rewrite the memory, and copies the data on the old page to the new page, this is "Copy On Write )".
Learning Materials: (1) http://blog.csdn.net/luoshengyang/article/details/6768304 (2) the Android framework secrets (3) the in-depth analysis of Android 5.0 System