关于AIDL接口定义中oneway的修饰符源码解析.

深入解析Android Binder机制中oneway修饰符的作用,阐述其如何确保异步调用的串行执行,以及对不同进程间远程接口调用的影响。

以下源码出自于Android 8.1

该部分源码基于我另外一篇文章,Binder通信流程浅析有提到,在binder进行传输数据时有提到这个方法binder_proc_transaction,该方法是把当前client要发送的数据t加入到队列中,并唤起binder线程执行该事务,当时忽略了一个细节oneway修饰符:

static bool binder_proc_transaction(struct binder_transaction *t,
				    struct binder_proc *proc,
				    struct binder_thread *thread)
{
   
   
	struct list_head *target_list = NULL;
	struct binder_node *node = t->buffer->target_node;
	struct binder_priority node_prio;
	bool oneway = !!(t->flags & TF_ONE_WAY);
	bool wakeup = true;

	BUG_ON(!node);
	binder_node_lock(node);
	node_prio.prio = node->min_priority;
	node_prio.sched_policy = node->sched_policy;

	if (oneway) {
   
   
		BUG_ON(thread);
		if (node->has_async_transaction) {
   
   
			target_list = &node->async_todo;
			wakeup = false;
		} else {
   
   
			node->has_async_transaction = 1;
		}
	}

	binder_inner_proc_lock(proc);

	if (proc->is_dead || (thread && thread->is_dead)) {
   
   
		binder_inner_proc_unlock(proc);
		binder_node_unlock(node);
		return false;
	}

	if (!thread && !target_list)
		thread = binder_select_thread_ilocked(proc);

	if (thread) 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值