When does the binder thread pool shrink?

1,438 views
Skip to first unread message

Michael Hsueh

unread,
Apr 27, 2012, 1:47:09 PM4/27/12
to android-...@googlegroups.com
I am reading through the binder code and trying to understand how the threading works. I know that the binder driver sends commands to increase the thread pool size when it detects that there is no free binder thread to service a command (up to the max of 16 threads). But I am not sure when these newly spawned threads are removed.

In IPCThreadState.cpp:

void IPCThreadState::
joinThreadPool(bool isMain) {
...
      result = executeCommand(cmd);
...
       if(result == TIMED_OUT && !isMain) {
           break;
       }
...
}

I see that the thread breaks out of the thread pool loop when result is set to TIMED_OUT, which in turn happens when the binder drive sends a command of BR_FINISHED. This would result in the handling binder thread to leave the thread pool and essentially end. But I looked through the binder driver source code and could not find any instance in which the driver would deliver this command to binder thread. Does this mean the binder thread pool will only grow in size and never shrink?

I would appreciate any help on this topic (I tried asking this in android-developers but then realized it was probably not the appropriate list for this type question).

Dianne Hackborn

unread,
Apr 27, 2012, 7:54:13 PM4/27/12
to android-...@googlegroups.com
It currently doesn't.


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-platform/-/183eS724tr8J.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.



--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Reply all
Reply to author
Forward
0 new messages