关于Android binder 方面的问题,恳求各位前来探讨,已经憋了三天了~~!!急急急~~!!

q3303635 2017-04-07 05:00:46
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_exclusivewait_event_interruptible

我在网上找了好久,都说这两个宏会将进程从调度队列里剔除,直到被唤醒。

我的问题是:如果一个进程两个线程,其中一个线程走到了内核的binder.c中的上述宏的地方,那么该进程是不是就被挂起了?还是只是该线程会被挂起?另一个线程仍然可以继续自己的工作?为什么

恳请各位大神前来指教,这个已经困扰我好几天了,网上我搜到的都说是挂起的进程,但binder相关文章里有的却说是线程睡眠,等待被唤醒,所以我就搞不懂了,真心搞不懂了,

恳请各位多多讲解,小弟谢谢了,衷心感谢!!!!

...全文
480 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧