9.4 Binder系统_驱动情景分析_服务使用过程
5. 服务使用过程
test_client进程:
用户态:
(1)已结获得了“hello”服务,handle=1;
(2)构造数据:code(那个函数)和函数参数
(3)发送ioctl后进入内核态,先写后读
(15)取出返回值
内核态:
(4)binder_ioctl被调用,根据handle在binder_proc中根据refs_by_desc找到binder_ref,在根据node找到服务的binder_node结构体,在根据proc找到目的进程test_server
(5)把数据放入test_server的todo链表
(6)唤醒test_server进程,然后在binder_thread_read中休眠
(17)被唤醒后把数据返回给用户空间
test_server进程:
用户态:
(8)取出数据,根据code调用哪个函数,并把参数给函数
(9)把返回值构造为数据
(10)调用ioctl来发送返回数据
内核态:
(7):被唤醒后把数据返回用户空间
(11)找到要回复的进程test_client
(12)把数据放入test_client的todo链表
(13)唤醒test_client进程
使用服务
构造数据(参数),格式:四字节全零+四字节字符串长度+字符串("weidongshan")
txn.code 表示的是哪个函数,就是个整数,为双方约定其代表某个函数
接着调用ioctl先写后读,把数据放入test_server的todo结构体,接着唤醒test_server,然后自身休眠
[ 1580.379989] test_client (1381, 1381), binder_thread_write : BC_TRANSACTION
[ 1580.386741] binder: 1381:1381 BC_TRANSACTION 9 -> 1373 - node 3, data beb20a5c-beb20a4c size 32-0
[ 1580.395634] test_client (1381, 1381), binder_transaction , print data :
[ 1580.402184] 0000: 00 . 00 . 00 . 00 . 0b . 00 . 00 . 00 . 77 w 00 . 65 e 00 . 69 i 00 . 64 d 00 .
[ 1580.411029] 0016: 6f o 00 . 6e n 00 . 67 g 00 . 73 s 00 . 68 h 00 . 61 a 00 . 6e n 00 . 00 . 00 .
[ 1580.419888] test_client (1381, 1381), binder_thread_read : BR_NOOP
test_server被唤醒后返回用户控件,取出code和参数后调用函数执行,得到返回值后构造BC_REPLY类型数据调用ioctl回复给test_client,
[ 1580.426103] test_server (1373, 1373), binder_thread_read : BR_TRANSACTION
[ 1580.432828] test_server (1373, 1373), binder_thread_read , print data :
[ 1580.439419] 0000: 00 . 00 . 00 . 00 . 0b . 00 . 00 . 00 . 77 w 00 . 65 e 00 . 69 i 00 . 64 d 00 .
[ 1580.448263] 0016: 6f o 00 . 6e n 00 . 67 g 00 . 73 s 00 . 68 h 00 . 61 a 00 . 6e n 00 . 00 . 00 .
[ 1580.457129] test_client (1381, 1381), binder_thread_read : BR_TRANSACTION_COMPLETE
//用户空间处理完数据后,把内核态保存数据的buffer释放掉
[ 1580.464710] test_server (1373, 1373), binder_thread_write : BC_FREE_BUFFER
[ 1580.471541] test_server (1373, 1373), binder_thread_write : BC_REPLY
[ 1580.477877] binder: 1373:1373 BC_REPLY 10 -> 1381:1381, data be857a5c-be857a4c size 4-0
[ 1580.485859] test_server (1373, 1373), binder_transaction , print data :
[ 1580.492455] 0000: 01 . 00 . 00 . 00 .
[ 1580.496109] test_client (1381, 1381), binder_thread_read : BR_NOOP
[ 1580.502282] test_server (1373, 1373), binder_thread_read : BR_NOOP
test_client收到BR_REPLY类型数据,返回数据1
[ 1580.508436] test_client (1381, 1381), binder_thread_read : BR_REPLY
[ 1580.514684] test_client (1381, 1381), binder_thread_read , print data :
[ 1580.521301] 0000: 01 . 00 . 00 . 00 .
[ 1580.524929] test_server (1373, 1373), binder_thread_read : BR_TRANSACTION_COMPLETE
[ 1580.532489] test_client (1381, 1381), binder_thread_write : BC_FREE_BUFFER
[ 1580.539345] test_server (1373, 1373), binder_thread_read : BR_NOOP
[ 1580.545510] test_client (1381, 1381), binder_thread_write : BC_RELEASE
9.4 Binder系统_驱动情景分析_服务使用过程的更多相关文章
- 9.2 Binder系统_驱动情景分析_服务注册过程
1. 几个重要结构体的引入给test_server添加一个goodbye服务, 由此引入以下概念: 进程间通信其实质也是需要三要素:源.目的.数据,源是自己,目的用handle表示:通讯的过程是源向实 ...
- 9.3 Binder系统_驱动情景分析_服务获取过程
4. 服务获取过程 test_client客户端: (1)在用户态先构造name=“hello”的数据(服务的名字是hello),调用ioctl发送数据给service_manager(handle= ...
- 9.5 Binder系统_驱动情景分析_transaction_stack机制
参考文章:http://www.cnblogs.com/samchen2009/p/3316001.html test_server服务进程可能有多个线程,而在发送数据的时候handle只表示了那个进 ...
- 9.6 Binder系统_驱动情景分析_server的多线程实现
当多个client对server发出请求的时候,如果server忙不过来的时候会创建多线程来处理请求 那么忙不过来由谁来判断? server进程有个binder_proc结构体,其里面有todo链表( ...
- Android系统--Binder系统具体框架分析(二)Binder驱动情景分析
Android系统--Binder系统具体框架分析(二)Binder驱动情景分析 1. Binder驱动情景分析 1.1 进程间通信三要素 源 目的:handle表示"服务",即向 ...
- Android : 跟我学Binder --- (4) 驱动情景分析
目录: Android : 跟我学Binder --- (1) 什么是Binder IPC?为何要使用Binder机制? Android : 跟我学Binder --- (2) AIDL分析及手动实现 ...
- 10.7 android输入系统_Dispatcher线程情景分析_Reader线程传递事件和dispatch前处理
android输入系统C++最上层文件是com_android_serve_input_InputManagerService.cpp global key:按下按键,启动某个APP可以自己指定,修改 ...
- [RK3288][Android6.0] 系统按键驱动流程分析【转】
本文转载自:http://blog.csdn.net/kris_fei/article/details/77894406 Rockchip的按键驱动位于 kernel/drivers/input/ke ...
- 一个简单web系统的接口性能分析及调优过程
在测试一个简单系统接口性能压力时,压到一定数量,程序总是崩溃,查看相关机器相关数据时,CPU.内存.IO占用均不高,问题自然出现在其它地方先介绍下系统部件架构 Resin版本为:[root@local ...
随机推荐
- jquery2.0.3 全部源码
/*! * Includes Sizzle.js 选择器,独立的库 * http://sizzlejs.com/ */ (function( window, undefined ) { //" ...
- 浅析.Net数据操作机制
举个栗子,获取新闻详情的案例. public ActionResult NewsView(int newsId) { var news = _newsService.GetNewsById(newsI ...
- C#结构函数
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- BZOJ 2037 区间DP
跟POJ 3042是一个类型的http://blog.csdn.net/qq_31785871/article/details/52954924 思路: 先排个序 (把初始位置也插进去) f[i][j ...
- 自己增删改查Razor页面
AccountContext db = new AccountContext(); public ActionResult Index() { return View(db.SysUsers); } ...
- jq实现回车键执行方法
$(function(){ $(document).keypress(function (e){ if(e.keyCode == 13){ //执行你想执行的方法,keyCode代表不同的按键 } } ...
- WPF框架ZFS
前文 项目开源地址(非正式版,开发版本), 码云Gitee地址: https://gitee.com/zhgg666/publicWpf XAML XAML能帮助团队真正实现UI与逻辑的剥离.XAM ...
- hive load文件第一个字段为NULL
在hive中,通常须要载入外部数据源.load文件时.第一个字段会出现NULL. 比如: 1.运行load语句: LOAD DATA LOCAL INPATH 'test.txt' OVERWRITE ...
- 阿里云 CentOS7.4 环境安装mysql5.7
1. 删除默认安装的数据库,无所谓的请略过 据说CentOS7.x版本会默认安装mariadb数据库,我有点强迫症,故卸载之: rpm -qa|grep mariadb yum remove mari ...
- screen-调节屏幕亮度
今天做项目的时候,需要实现一个功能,就是进入一个应用,在这个应用中,屏幕的亮度变为最亮.关键代码如下 bt1.setOnClickListener(new OnClickListener() { @O ...