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.

 

 

 

一本以情景方式对Android的源代码进行深入分析的书。内容广泛,以对Framework层的分析为主,兼顾Native层和Application层;分析深入,每一部分源代码的分析都力求透彻;针对性强,注重实际应用开发需求,书中所涵盖的知识点都是Android应用开发者和系统开发者需要重点掌握的。共10章,第1章介绍了阅读本书所需要做的准备工作,主要包括对Android系统架构和源码阅读方法的介绍;第2章通过对Android系统中的MediaScanner进行分析,详细讲解了Android中十分重要的JNI技术;第3章分析了init进程,揭示了通过解析init.rc来启动Zygote以及属性服务的工作原理;第4章分析了Zygote、SystemServer等进程的工作机制,同时还讨论了Android的启动速度、虚拟机HeapSize的大小调整、Watchdog工作原理等问题;第5章讲解了Android系统中常用的类,包括sp、wp、RefBase、Thread等类,同步类,以及Java中的Handler类和Looper类,掌握这些类的知识后方能在后续的代码分析中做到游刃有余;第6章以MediaServer为切入点,对Android中极为重要的Binder进行了较为全面的分析,深刻揭示了其本质。第7章对Audio系统进行了深入的分析,尤其是AudioTrack、AudioFlinger和AudioPolicyService等的工作原理。第8章深入讲解了Surface系统的实现原理,分析了Surface与Activity之间以及Surface与SurfaceFlinger之间的关系、SurfaceFlinger的工作原理、Surface系统中的帧数据传输以及LayerBuffer的工作流程。第9章对Vold和Rild的原理和机制进行了深入的分析,同时还探讨了Phone设计优化的问题;第10章分析了多媒体系统中MediaScanner的工作原理。适合有一定基础的Android应用开发工程师和系统工程师阅读。通过对本书的学习,大家将能更深刻地理解Android系统,从而自如应对实际开发中遇到的难题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值