Recently, I had read source codes of Binder Driver. I can understand most,
except that I was blocked somewhere which I am describing as follows:
when service manager enter binder_loop function, it send command
of BC_ENTER_LOOPER to binder driver, which it cause the binder_thread of
this process change its looper flag to be BINDER_LOOPER_STATE_ENTERED.
and then service manager will wait in binder_thread_read function. (ret =
wait_event_interruptible_exclusive(proc->wait, binder_has_proc_work(proc,
thread));)
while another processor sending add service requirement, it will wake up
service manager, and it will resume processing from where it wait.
at the end of the function binder_thread_read, there are codes as follows:
*done:*
*
*
* *consumed = ptr - buffer;*
* if (proc->requested_threads + proc->ready_threads == 0 &&*
* proc->requested_threads_started < proc->max_threads &&*
* (thread->looper & (BINDER_LOOPER_STATE_REGISTERED |*
* BINDER_LOOPER_STATE_ENTERED)) /* the user-space code fails to */*
* /*spawn a new thread if we leave this out */) {*
* proc->requested_threads++;*
* if (binder_debug_mask & BINDER_DEBUG_THREADS)*
* printk(KERN_INFO "binder: %d:%d BR_SPAWN_LOOPER\n",*
* proc->pid, thread->pid);*
* if (put_user(BR_SPAWN_LOOPER, (uint32_t __user *)buffer))*
* return -EFAULT;*
* }*
the condition of the red part codes seem to be fulfiled, and binder driver
will write *BR_SPAWN_LOOPER in the front of reading buffer back to service
manager.*
*however, there is no case to deal with this command, and it will return -1
immediately. *
*
*
*some people said that, **thread->looper should be zero. But why? where did
this variable changed?*
*
*
*can someone help me to out.*
*thanks a lot.*
--
unsubscribe: [email protected]
website: http://groups.google.com/group/android-kernel