Difference between revisions of "Android Zygote Startup"
From eLinux.org
(add bootup sequence notes) |
(→Sequence of startup steps: add system server startup steps) |
||
| Line 28: | Line 28: | ||
* the Zygote socket is registered (for later communication to start apps) | * the Zygote socket is registered (for later communication to start apps) | ||
* classes and resources are preloaded | * classes and resources are preloaded | ||
| + | * if startSystemServer is set, then the system server is started | ||
| + | ** the command line to the system server is: | ||
| + | --setuid=1000 --setgid=1000 \ | ||
| + | --setgroups=1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,3001,3002,3003 | ||
| + | --capabilities=130104352,130104352 \ | ||
| + | --runtime-init | ||
| + | --nice-name=system_server | ||
| + | ** the class which starts executing is: com.android.server.SystemServer | ||
| + | ** a call is made to Zygote.forkSystemServer() to actually start this other process | ||
* zygote runs in "select loop mode", where a single process spins waiting for communication to start subsequent apps | * zygote runs in "select loop mode", where a single process spins waiting for communication to start subsequent apps | ||
** see runSelectLoopMode() | ** see runSelectLoopMode() | ||
Revision as of 19:17, 2 September 2010
Here are some miscellaneous notes on Android startup of the zygote process.
This information is true for eclair, as of August 2010.
Sequence of startup steps
- init runs the C++ program /system/bin/app_process, and gives the resulting process the name "zygote"
- This is based on the line from init.rc:
service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
- app_process executes, and executes a runtime environment for a dalvik class
- app_process usage claims to be:
Usage: app_process [java-options] cmd-dir start-class-name [options]
- but you can specify --zygote in place of the start-class-name.
- In the bootup case, --zygote is used
- source for 'app_process is in frameworks/base/cmds/app_process/app_main.cpp
- this is the program to debug when debugging zygote/dalvik itself
- app_process does a 'runtime.start("com.android.internal.os.ZygoteInit", startSystemServer)
- the startSystemServer flag is passed as a parameter on to app_process, to indicate whether to start the system server (duh)
- runtime is an instance of class AppRuntime, which is sub-classed from AndroidRuntime
- AndroidRuntime is the main class for starting the dalvik runtime environment
- source is in frameworks/base/core/jni/AndroidRuntime.cpp
- the start() method starts the virtual machine
- LOG_BOOT_PROGRESS_START is emitted, with systemTime(SYSTEM_TIME_MONOTONIC)
- startVM() is called
- eventually, callStaticVoidMethod() is called, to actually start executing the start class with method "main" in Dalvik code
- com.android.internal.os.ZygoteInit:main() starts executing
- source is at: frameworks/base/core/java/com/android/internal/os/ZygoteInit.java
- the profiler is started
- the Zygote socket is registered (for later communication to start apps)
- classes and resources are preloaded
- if startSystemServer is set, then the system server is started
- the command line to the system server is:
--setuid=1000 --setgid=1000 \ --setgroups=1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,3001,3002,3003 --capabilities=130104352,130104352 \ --runtime-init --nice-name=system_server
- the class which starts executing is: com.android.server.SystemServer
- a call is made to Zygote.forkSystemServer() to actually start this other process
- zygote runs in "select loop mode", where a single process spins waiting for communication to start subsequent apps
- see runSelectLoopMode()
- new connections are accepted (and put into array "peers")
- the spawn command received over the network is executed by calling the runOnce() method
- source code for this is at: frameworks/base/core/java/com/android/internal/os/ZygoteConnection.java
- see runSelectLoopMode()
- eventually, a call is made to Zygote.forkAndSpecialize(), which does the actual forking