关于Android binder 方面的问题,恳求各位前来探讨,已经憋了三天了~~!!急急急~~!!
Android binder 相关
binder底层,在文件kernel\kernel\drivers\android\binder.c里
函数:binder_thread_read (struct binder_proc *proc, struct binder_thread *thread,
void __user *buffer, int size, signed long *consumed, int non_block)
{
void __user *ptr = buffer + *consumed;
void __user *end = buffer + size;
int ret = 0;
int wait_for_proc_work;
if (*consumed == 0) {
if (put_user(BR_NOOP, (uint32_t __user *)ptr))
return -EFAULT;
ptr += sizeof(uint32_t);
}
.......(中间省略)
binder_set_nice(proc->default_priority);
if (non_block) {
if (!binder_has_proc_work(proc, thread))
ret = -EAGAIN;
} else
ret = wait_event_interruptible_exclusive(proc->wait, binder_has_proc_work(proc, thread));
} else {
if (non_block) {
if (!binder_has_thread_work(thread))
ret = -EAGAIN;
} else
ret = wait_event_interruptible(thread->wait, binder_has_thread_work(thread));
}
mutex_lock(&binder_lock);
if (wait_for_proc_work)
proc->ready_threads--;
thread->looper &= ~BINDER_LOOPER_STATE_WAITING;
.......(中间省略)
return 0;
}
在上述代码中的红色部分,wait_event_interruptible_exclusive 和wait_event_interruptible
我在网上找了好久,都说这两个宏会将进程从调度队列里剔除,直到被唤醒。
我的问题是:如果一个进程有两个线程,其中一个线程走到了内核的binder.c中的上述宏的地方,那么该进程是不是就被挂起了?还是只是该线程会被挂起?另一个线程仍然可以继续自己的工作?为什么?
恳请各位大神前来指教,这个已经困扰我好几天了,网上我搜到的都说是挂起的进程,但binder相关文章里有的却说是线程睡眠,等待被唤醒,所以我就搞不懂了,真心搞不懂了,
恳请各位多多讲解,小弟谢谢了,衷心感谢!!!!