Loading libs/binder/IPCThreadState.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -489,12 +489,14 @@ void IPCThreadState::flushCommands() void IPCThreadState::blockUntilThreadAvailable() { pthread_mutex_lock(&mProcess->mThreadCountLock); mProcess->mWaitingForThreads++; while (mProcess->mExecutingThreadsCount >= mProcess->mMaxThreads) { ALOGW("Waiting for thread to be free. mExecutingThreadsCount=%lu mMaxThreads=%lu\n", static_cast<unsigned long>(mProcess->mExecutingThreadsCount), static_cast<unsigned long>(mProcess->mMaxThreads)); pthread_cond_wait(&mProcess->mThreadCountDecrement, &mProcess->mThreadCountLock); } mProcess->mWaitingForThreads--; pthread_mutex_unlock(&mProcess->mThreadCountLock); } Loading Loading @@ -534,7 +536,12 @@ status_t IPCThreadState::getAndExecuteCommand() } mProcess->mStarvationStartTimeMs = 0; } // Cond broadcast can be expensive, so don't send it every time a binder // call is processed. b/168806193 if (mProcess->mWaitingForThreads > 0) { pthread_cond_broadcast(&mProcess->mThreadCountDecrement); } pthread_mutex_unlock(&mProcess->mThreadCountLock); } Loading libs/binder/ProcessState.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -399,6 +399,7 @@ ProcessState::ProcessState(const char *driver) , mThreadCountLock(PTHREAD_MUTEX_INITIALIZER) , mThreadCountDecrement(PTHREAD_COND_INITIALIZER) , mExecutingThreadsCount(0) , mWaitingForThreads(0) , mMaxThreads(DEFAULT_MAX_BINDER_THREADS) , mStarvationStartTimeMs(0) , mThreadPoolStarted(false) Loading libs/binder/include/binder/ProcessState.h +4 −1 Original line number Diff line number Diff line Loading @@ -107,11 +107,14 @@ private: int mDriverFD; void* mVMStart; // Protects thread count variable below. // Protects thread count and wait variables below. pthread_mutex_t mThreadCountLock; // Broadcast whenever mWaitingForThreads > 0 pthread_cond_t mThreadCountDecrement; // Number of binder threads current executing a command. size_t mExecutingThreadsCount; // Number of threads calling IPCThreadState::blockUntilThreadAvailable() size_t mWaitingForThreads; // Maximum number for binder threads allowed for this process. size_t mMaxThreads; // Time when thread pool was emptied Loading Loading
libs/binder/IPCThreadState.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -489,12 +489,14 @@ void IPCThreadState::flushCommands() void IPCThreadState::blockUntilThreadAvailable() { pthread_mutex_lock(&mProcess->mThreadCountLock); mProcess->mWaitingForThreads++; while (mProcess->mExecutingThreadsCount >= mProcess->mMaxThreads) { ALOGW("Waiting for thread to be free. mExecutingThreadsCount=%lu mMaxThreads=%lu\n", static_cast<unsigned long>(mProcess->mExecutingThreadsCount), static_cast<unsigned long>(mProcess->mMaxThreads)); pthread_cond_wait(&mProcess->mThreadCountDecrement, &mProcess->mThreadCountLock); } mProcess->mWaitingForThreads--; pthread_mutex_unlock(&mProcess->mThreadCountLock); } Loading Loading @@ -534,7 +536,12 @@ status_t IPCThreadState::getAndExecuteCommand() } mProcess->mStarvationStartTimeMs = 0; } // Cond broadcast can be expensive, so don't send it every time a binder // call is processed. b/168806193 if (mProcess->mWaitingForThreads > 0) { pthread_cond_broadcast(&mProcess->mThreadCountDecrement); } pthread_mutex_unlock(&mProcess->mThreadCountLock); } Loading
libs/binder/ProcessState.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -399,6 +399,7 @@ ProcessState::ProcessState(const char *driver) , mThreadCountLock(PTHREAD_MUTEX_INITIALIZER) , mThreadCountDecrement(PTHREAD_COND_INITIALIZER) , mExecutingThreadsCount(0) , mWaitingForThreads(0) , mMaxThreads(DEFAULT_MAX_BINDER_THREADS) , mStarvationStartTimeMs(0) , mThreadPoolStarted(false) Loading
libs/binder/include/binder/ProcessState.h +4 −1 Original line number Diff line number Diff line Loading @@ -107,11 +107,14 @@ private: int mDriverFD; void* mVMStart; // Protects thread count variable below. // Protects thread count and wait variables below. pthread_mutex_t mThreadCountLock; // Broadcast whenever mWaitingForThreads > 0 pthread_cond_t mThreadCountDecrement; // Number of binder threads current executing a command. size_t mExecutingThreadsCount; // Number of threads calling IPCThreadState::blockUntilThreadAvailable() size_t mWaitingForThreads; // Maximum number for binder threads allowed for this process. size_t mMaxThreads; // Time when thread pool was emptied Loading