binder机制分析
1. binder基本概念
1.1 特点
1)binder 是一种基于C/S通信模式的IPC(Inter_Process Communication)。
2)在传输过程中近需要一次copy,为发送添加UID/PID身份,既支持实名binder也支持匿名binder,安全性高
3)binder驱动是标准的linux驱动,但是不是驱动专门的硬件,而是虚拟出一个binder管理设备,用于管理binder通信。
1.2
2. binder驱动源码分析
2.1 binder初始化函数binder_init
static int __init binder_init(void)
{
int ret;
char *device_name, *device_tmp;
struct binder_device *device;
struct hlist_node *tmp;
char *device_names = NULL;
ret = binder_alloc_shrinker_init();//初始化binder缓冲区
if (ret)
return ret;
atomic_set(&binder_transaction_log.cur, ~0U);
atomic_set(&binder_transaction_log_failed.cur, ~0U);
binder_debugfs_dir_entry_root = debugfs_create_dir("binder", NULL);
if (binder_debugfs_dir_entry_root)
binder_debugfs_dir_entry_proc = debugfs_create_dir("proc",
binder_debugfs_dir_entry_root);
if (binder_debugfs_dir_entry_root) {
debugfs_create_file("state",
0444,
binder_debugfs_dir_entry_root,
NULL,
&binder_state_fops);
debugfs_create_file("stats",
0444,
binder_debugfs_dir_entry_root,
NULL,
&binder_stats_fops);
debugfs_create_file("transactions",
0444,
binder_debugfs_dir_entry_root,
NULL,
&binder_transactions_fops);
debugfs_create_file("transaction_log",
0444,
binder_debugfs_dir_entry_root,
&binder_transaction_log,
&binder_transaction_log_fops);
debugfs_create_file("failed_transaction_log",
0444,
binder_debugfs_dir_entry_root,
&binder_transaction_log_failed,
&binder_transaction_log_fops);
}
if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) &&
strcmp(binder_devices_param, "") != 0) {
/*
* Copy the module_parameter string, because we don't want to
* tokenize it in-place.
*/
device_names = kstrdup(binder_devices_param, GFP_KERNEL);//给device_names申请空间
if (!device_names) {
ret = -ENOMEM;
goto err_alloc_device_names_failed;
}
device_tmp = device_names;
while ((device_name = strsep(&device_tmp, ","))) {
ret = init_binder_device(device_name); //注册misc设备
if (ret)
goto err_init_binder_device_failed;
}
}
ret = init_binderfs();
if (ret)
goto err_init_binder_device_failed;
return ret;
err_init_binder_device_failed:
hlist_for_each_entry_safe(device, tmp, &binder_devices, hlist) {
misc_deregister(&device->miscdev);
hlist_del(&device->hlist);
kfree(device);
}
kfree(device_names);
err_alloc_device_names_failed:
debugfs_remove_recursive(binder_debugfs_dir_entry_root);
return ret;
}
binder_init函数有三个作用:
1) 初始化binder misc设备
2) 给设备分配内存
3) 调用list_add,将misc device设备放入设备列表中misc_list
2.2 binder初始化函数binder_init
binder机制分析的更多相关文章
- Android系统进程间通信Binder机制在应用程序框架层的Java接口源代码分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6642463 在前面几篇文章中,我们详细介绍了A ...
- 从Android源码的角度分析Binder机制
欢迎访问我的个人博客,原文链接:http://wensibo.top/2017/07/03/Binder/ ,未经允许不得转载! 前言 大家好,好久不见,距离上篇文章已经有35天之久了,因为身体不舒服 ...
- 从驱动层分析android的Binder机制-android学习之旅(83)
前言及知识准备 Binder驱动程序 Service组件的注册和启动 Clinet应用获取服务 本次主要介绍Android平台下Binder进程间机制.从机制的组成出发,将按照Binder驱动程序.B ...
- Android中的Binder机制的简要理解
转载自:http://www.linuxidc.com/Linux/2012-07/66195.htm http://blog.csdn.net/sunxingzhesunjinbiao/articl ...
- 6.7 Binder机制
Binder在Android系统中江湖地位非常之高.在Zygote孵化出system_server进程后,在system_server进程中出初始化支持整个Android framework的各种各样 ...
- Android深入浅出之Binder机制
一说明 Android系统最常见也是初学者最难搞明白的就是Binder了,很多很多的Service就是通过Binder机制来和客户端通讯交互的.所以搞明白Binder的话,在很大程度上就能理解程序运行 ...
- Android Binder机制简单了解
Binder -- 一种进程间通信(IPC)机制, 基于OpenBinder来实现 毫无疑问, 老罗的文章是不得不看的 Android进程间通信(IPC)机制Binder简要介绍和学习计划 浅谈Ser ...
- Binder机制,从Java到C (大纲)
转载请标注:张小燕:http://www.cnblogs.com/zhangxinyan/p/3487381.html 前段时间一直在看有关Binder机制的内容,觉得受益匪浅,整理记录于此,大家请随 ...
- Binder机制,从Java到C (2. IPC in System Service :AMS)
1.建立Activity和Service的IPC之前 在上一篇 Binder机制,从Java到C (1. IPC in Application Remote Service) 里面有说到Activi ...
- Binder机制,从Java到C (3. ServiceManager in Java)
上一篇 Binder机制,从Java到C (2. IPC in System Service :AMS) 中提到 Application是通过ServiceManager找到了AMS 的servic ...
随机推荐
- 语言-页面-模板-thymeleaf
一.语法 二.使用 Thymeleaf入门到吃灰 - 鞋破露脚尖儿 - 博客园 (cnblogs.com)
- Docker 安装流程-CentOS
0.安装Docker Docker 分为 CE 和 EE 两大版本.CE 即社区版(免费,支持周期 7 个月),EE 即企业版,强调安全,付费使用,支持周期 24 个月. Docker CE 分为 s ...
- 移动端及pc端适配
1.rem搭配CSS预处理器使用 这里我就用vue+less来简单操作一下,具体可以封装到底层,这里暂且演示一下原理. 这里推荐一下使用我的自制脚手架 (songyao-cli) 来快速生成一个vue ...
- springboot+vue本地部署
springboot+vue本地部署 最近完成项目,需要部署到本地,期间遇到了一些问题,最后写下流程以作记录. springboot打包 这块的内容较为简单一般为在pom.xml中加入 <bui ...
- 第三章 mysql 数据库接口程序以及SQL语句操作
mysql 数据库接口程序以及SQL语句操作 用于管理数据库: 命令接口自带命令 DDL:数据定义语言(create drop ) DCL: 数据控制语言(grant revoke) DML: 数据 ...
- ftp服务无法覆盖同名文件
1.linux修改/etc/pure-ftpd/pure-ftpd.conf的AutoRename yes 重启ftp服务 2.windows server修改 选中ftp站点,选择右侧高级设置,选 ...
- 21 forms组件-参数initial&instance应用
简单来讲: 如果你想传入前端的页面中附带值,那么在实例化forms中: form = SecondModelForm(data=request.POST, instance=permission_ob ...
- 半成品 java 身份证校验
public static Boolean is18Card(String idCard18) { //证件省份 HashMap<String, String> aCity = new H ...
- VirtualBox_Ubuntu22.10_Terminal无法打开
https://blog.csdn.net/weixin_43959807/article/details/128872860
- nuxt中处理跨域
一.安装 npm install @nuxtjs/axios @nuxtjs/proxy -S 二.nuxt.config.js进行配置 modules:[ '@nuxtjs/axios' ' ...