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).