service manager和binder service的关系

http://www.cloudchou.com/android/post-327.html


service manager是所有binder service的管理者,但它并不是这些binder service的创建者。

这些binder service有些是init进程启动的服务创建的,有些是system_server进程创建的,但是service manager会管理所有binder service的信息,方便client查询以及调用。

service manager是由init进程直接启动的,在init.rc里有

1
2
3
4
5
6
7
8
9
service servicemanager /system/bin/servicemanager
    class core
    user system
    group system
    critical
    onrestart restart zygote
    onrestart restart media
    onrestart restart surfaceflinger
    onrestart restart drm

ActivityManagerService,PackageManagerService等由system_server进程启动的binder service实际上并没有单独的进程,它们只是system_server的一个子线程。init进程会启动surface flinger,media server, drmserver等服务,在这些服务里会创建binder service,并注册到service manager。

init.rc声明了surfaceflinger:

1
2
3
4
5
service surfaceflinger /system/bin/surfaceflinger
    class main
    user system
    group graphics drmrpc
		onrestart restart zygote

native binder service 和 java 层的binder service,都会交由service manager注册,然后由service manager管理。客户端使用binder service时需要向service manager查询得到binder service在当前进程的一个代理,通过代理与binder service的服务端交互。

binder线程

id="uyan_ifr_3188747" scrolling="no" frameborder="0" src="http://api.v2.uyan.cc/v4/comment/?uid=1832578&frameid=3188747&du=&su=www.cloudchou.com%2F%3Fp%3D327&pic=http%3A%2F%2Fwww.cloudchou.com%2Fwp-content%2Fuploads%2F2014%2F04%2Fbinder%25E7%25BA%25BF%25E7%25A8%258B.png&url=http%3A%2F%2Fwww.cloudchou.com%2Fandroid%2Fpost-327.html&title=service%20manager%E5%92%8Cbinder%20service%E7%9A%84%E5%85%B3%E7%B3%BB%20-%20Cloud%20Chou%27s%20Tech%20Blog&t=1477381902181" style="height: 687px; width: 626px; display: block !important; border-width: 0px !important; border-style: none !important; overflow: hidden !important;">


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值