Android IPC 通讯机制源码分析
2010-05-29 05:27:00 来源:WEB开发网.......................................
}
} else {//这一段我们获取到了service_mananger process 注册在binder kernle的进程信息
target_node = binder_context_mgr_node; //BINDER_SET_CONTEXT_MGR 注册了service
if (target_node == NULL) { //manager
return_error = BR_DEAD_REPLY;
goto err_no_context_mgr_node;
}
}
e->to_node = target_node->debug_id;
target_proc = target_node->proc; //得到目标进程service_mananger 的结构
if (target_proc == NULL) {
return_error = BR_DEAD_REPLY;
goto err_dead_binder;
}
....................
}
if (target_thread) {
e->to_thread = target_thread->pid;
target_list = &target_thread->todo;
target_wait = &target_thread->wait; //得到service manager挂起的线程
} else {
target_list = &target_proc->todo;
target_wait = &target_proc->wait;
}
............................................
case BINDER_TYPE_BINDER:
case BINDER_TYPE_WEAK_BINDER: {
..........................
ref = binder_get_ref_for_node(target_proc, node); //在Binder kernel中创建
.......................... //查找到的service参考
} break;
............................................
if (target_wait)
wake_up_interruptible(target_wait); //唤醒挂起的线程 处理caller process请求
............................................//处理命令可以看svcmgr_handler
}
到这里我们已经通过getService连接到service manager进程了,service manager进程得到请求后,如果他的状态是挂起的话,将被唤醒。现在我们来看一下service manager中的binder_loop函数。
Service_manager.c
void binder_loop(struct binder_state *bs, binder_handler func)
更多精彩
赞助商链接