Android is actually an application in the Linux system, the corresponding program is app_process, the program is declared in the init.rc, the Linux startup will start the zygote (app_process) process (the program is implemented by Java code, Run by Dalvik virtual machine, corresponding code in Latest-android-2.3.7_r1\android-2.3.7_r1\frameworks\base\core\java\com\android\internal\os\ In Zygoteinit.java)
Directory of files in the Android system
Init.rc file path and content in Android 2.3 source code
Latest-android-2.3.7_r1\android-2.3.7_r1\frameworks\base\core\java\com\android\internal\os\ Key code in Zygoteinit.java
The service-side socket is first started in the main function to receive commands to start the Dalvik process
Then load the shared classes and resource files on the Android system, and Zygoteinit will load the shared class based on the preload_classes file.
Preload_classes file location and content
A total of 1830 classes are listed in the file, all of which need to be loaded, loading is slow, but loading means that most of the shared classes are already loaded when the Android app is running, which improves the speed of the Android app
The resource file load is loaded according to the declaration in Latest-android-2.3.7_r1\android-2.3.7_r1\frameworks\base\core\res\res\values\arrays.xml
The contents of the file are as follows
After loading the above resources Zygote will hatch out the first Dalvik process systemserver,systemserver will create a socket client, which is managed by Activitymanageservice, All subsequent Dalvik processes will be started indirectly through the socket client, and when a new APK process is required, AMS sends a start command to the socket server of the zygote process through the socket client, and Zygote will hatch a new process
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android source code----Android System start-up process (initial research source code, improper expression also forgive me)