码迷,mamicode.com
首页 > 系统相关 > 详细

Linux嵌入式学习-远程过程调用-Binder系统

时间:2017-05-28 22:35:04      阅读:338      评论:0      收藏:0      [点我收藏+]

标签:目录   oop   proc   android系统   man   注册服务   frame   gets   context   

 Binder系统的C程序使用示例
IPC : Inter-Process Communication, 进程间通信
RPC : Remote Procedure Call, 远程过程调用

这里我们直接只用android系统中已经实现好的Bindrt系统。

具体源代码在 frameworks\native\cmds\servicemanager\目录下。


service_manager.c :
a. binder_open
b. binder_become_context_manager
c. binder_loop(bs, svcmgr_handler);
   c.1 res = ioctl(bs->fd, BINDER_WRITE_READ, &bwr);
   c.2 binder_parse
          // 解析
          // 处理  : svcmgr_handler
                       SVC_MGR_GET_SERVICE/SVC_MGR_CHECK_SERVICE : 获取服务
                       SVC_MGR_ADD_SERVICE : 注册服务         
          // 回复         

bctest.c
注册服务的过程:
a. binder_open
b. binder_call(bs, &msg, &reply, 0, SVC_MGR_ADD_SERVICE)
                   // 含有服务的名字
                         // 它会含有servicemanager回复的数据
                                 // 0表示servicemanager
                                    // code: 表示要调用servicemanager中的"addservice函数"


获取服务的过程:
a. binder_open
b. binder_call(bs, &msg, &reply, target, SVC_MGR_CHECK_SERVICE)
                   // 含有服务的名字
                         // 它会含有servicemanager回复的数据, 表示提供服务的进程
                                 // 0表示servicemanager
                                    // code: 表示要调用servicemanager中的"getservice函数"
                                   

binder.c (封装好的C函数)

Linux嵌入式学习-远程过程调用-Binder系统

标签:目录   oop   proc   android系统   man   注册服务   frame   gets   context   

原文地址:http://www.cnblogs.com/ynxf/p/6916785.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!