【发布时间】:2018-04-13 09:06:41
【问题描述】:
我正在学习活页夹驱动程序。它有一个结构binder_thread 用于保存线程信息。我发现它使用分配有current->pid 的binder_thread.pid 来区分彼此。例如binder_get_thread方法中,该字段用于判断当前线程是否已添加到树中。
static struct binder_thread *binder_get_thread(struct binder_proc *proc)
{
struct binder_thread *thread = NULL;
struct rb_node *parent = NULL;
struct rb_node **p = &proc->threads.rb_node;
while (*p) {
parent = *p;
thread = rb_entry(parent, struct binder_thread, rb_node);
if (current->pid < thread->pid)
p = &(*p)->rb_left;
else if (current->pid > thread->pid)
p = &(*p)->rb_right;
else
break;
}
.....
}
但是据我所知,current->pid是当前进程id,怎么可以用来区分线程呢?
【问题讨论】:
标签: android linux-device-driver android-binder