博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android Zygote Startup
阅读量:2342 次
发布时间:2019-05-10

本文共 3620 字,大约阅读时间需要 12 分钟。

Here are some miscellaneous notes on Android startup of the zygote process.

This information is true for eclair, as of August 2010.

Sequence of Zygote 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 \com.android.server.SystemServer
    • 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
  • eventually, a call is made to Zygote.forkAndSpecialize(), which does the actual forking

Sequence of system_server (or SystemServer) startup steps

Source for the SystemServer is in:frameworks/base/services/java/com/android/server/SystemServer.java

in the "ServerThread::run()" method, the following startup occurs:

  • LOG_BOOT_PROGRESS_SYSTEM_RUN is emitted
  • Lots of critical services are started:
    • Entropy Service
    • Power Manager
    • Activity Manager
    • Telephony Registry
    • Package Manager
    • Account Manager
    • Content Manager
    • System Content Providers
    • Battery Service
    • Hardware Service
    • Alarm Manager
    • Init Watchdog
    • Sensor Service
    • Window Manager
  • Additional services may be started as well:
    • Status Bar
    • Clipboard Service
    • Input Method Service
    • NetStat Service
    • Connectivity Service
    • Accessibility Manager
    • Notification Manager
    • Mount Service
    • Device Storage Monitor
    • Location Manager
    • Search Service
    • Checkin Service
    • Wallpaper Service
    • Audio Service
    • Headset Observer
    • Dock Observer
    • Backup Service
    • AppWidget Service

转载地址:http://fhfvb.baihongyu.com/

你可能感兴趣的文章
java 获取路径
查看>>
spring boot 打印sql
查看>>
我的死锁经历
查看>>
spring boot日志配置
查看>>
list排序
查看>>
搭建zookeeper集群
查看>>
1005. 数独
查看>>
1006. 求和游戏
查看>>
IDEA eclipse 控制台日志输出到文件
查看>>
1022. Fib数列
查看>>
一些开源项目
查看>>
将博客搬至CSDN
查看>>
MySQL 中事务的实现
查看>>
CheckStyle
查看>>
IDE配置jvm参数
查看>>
内存溢出
查看>>
Spring Cloud 声明式服务调用 Feign
查看>>
JVM实用参数(一)JVM类型以及编译器模式
查看>>
spring cloud config 属性加解密
查看>>
rabbitmq安装
查看>>