您的位置:首页 > 移动开发 > Android开发

Zygote (深入理解android 卷1)

2014-12-16 16:01 441 查看
Zygote is just one Native’s app. It is created by theinit.rc. First, zygote’s name is app_process before. After the Linux’s pctrlcalling changed to zygote.

Zygote creates vm and system_server.

In AndroidRuntime.cpp

 

1.     Create vm

Checkthe JNI function

Setup the heapsize to 16MB, someone will set to 32MB.

Checkthe resource of JNI. The Global reference cannot over 2000.

Callthe JNI_CreateJavaVM to create the VM. pEnv will send the JNIEnv value back tothe current job.

2.     Register function

InstartReg function, the system will call register_init_procs() to enroll one JNIfunction.

Andit will call mProc(env). This function is just for register the JNI function.

3.     Call Java function by JNI.(CallStaticVoidMethod)

The steps shows below:

1.     Register socket for zygote.

2.     Preload the classes and resources.

3.     Start systemserver

4.     runSelectLoopMode()

5.     call run

 

 

SystemServer

IfSS killed, the Zygote will suicide with it.

Goals:

 Init the native level.

Callstartclass. Call Binder to connect.

Startpower manager, battery manager, watchdog, window Manager, activity manager.

 

Createthe zygote

Sendthe signal to the zygote and create one thread. Set property, binderconncetion. At last , it will call invokestaticmain.

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: