Zygote (深入理解android 卷1)

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.

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章