Loading include/binder/ProcessState.h +2 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,8 @@ private: size_t mExecutingThreadsCount; // Maximum number for binder threads allowed for this process. size_t mMaxThreads; // Time when thread pool was emptied int64_t mStarvationStartTimeMs; mutable Mutex mLock; // protects everything below. Loading libs/binder/IPCThreadState.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -24,12 +24,14 @@ #include <cutils/sched_policy.h> #include <utils/Log.h> #include <utils/SystemClock.h> #include <utils/threads.h> #include <private/binder/binder_module.h> #include <private/binder/Static.h> #include <errno.h> #include <inttypes.h> #include <pthread.h> #include <sched.h> #include <signal.h> Loading Loading @@ -434,12 +436,25 @@ status_t IPCThreadState::getAndExecuteCommand() pthread_mutex_lock(&mProcess->mThreadCountLock); mProcess->mExecutingThreadsCount++; if (mProcess->mExecutingThreadsCount >= mProcess->mMaxThreads && mProcess->mStarvationStartTimeMs == 0) { mProcess->mStarvationStartTimeMs = uptimeMillis(); } pthread_mutex_unlock(&mProcess->mThreadCountLock); result = executeCommand(cmd); pthread_mutex_lock(&mProcess->mThreadCountLock); mProcess->mExecutingThreadsCount--; if (mProcess->mExecutingThreadsCount < mProcess->mMaxThreads && mProcess->mStarvationStartTimeMs != 0) { int64_t starvationTimeMs = uptimeMillis() - mProcess->mStarvationStartTimeMs; if (starvationTimeMs > 100) { ALOGE("binder thread pool (%zu threads) starved for %" PRId64 " ms", mProcess->mMaxThreads, starvationTimeMs); } mProcess->mStarvationStartTimeMs = 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 @@ -343,6 +343,7 @@ ProcessState::ProcessState() , mThreadCountDecrement(PTHREAD_COND_INITIALIZER) , mExecutingThreadsCount(0) , mMaxThreads(DEFAULT_MAX_BINDER_THREADS) , mStarvationStartTimeMs(0) , mManagesContexts(false) , mBinderContextCheckFunc(NULL) , mBinderContextUserData(NULL) Loading Loading
include/binder/ProcessState.h +2 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,8 @@ private: size_t mExecutingThreadsCount; // Maximum number for binder threads allowed for this process. size_t mMaxThreads; // Time when thread pool was emptied int64_t mStarvationStartTimeMs; mutable Mutex mLock; // protects everything below. Loading
libs/binder/IPCThreadState.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -24,12 +24,14 @@ #include <cutils/sched_policy.h> #include <utils/Log.h> #include <utils/SystemClock.h> #include <utils/threads.h> #include <private/binder/binder_module.h> #include <private/binder/Static.h> #include <errno.h> #include <inttypes.h> #include <pthread.h> #include <sched.h> #include <signal.h> Loading Loading @@ -434,12 +436,25 @@ status_t IPCThreadState::getAndExecuteCommand() pthread_mutex_lock(&mProcess->mThreadCountLock); mProcess->mExecutingThreadsCount++; if (mProcess->mExecutingThreadsCount >= mProcess->mMaxThreads && mProcess->mStarvationStartTimeMs == 0) { mProcess->mStarvationStartTimeMs = uptimeMillis(); } pthread_mutex_unlock(&mProcess->mThreadCountLock); result = executeCommand(cmd); pthread_mutex_lock(&mProcess->mThreadCountLock); mProcess->mExecutingThreadsCount--; if (mProcess->mExecutingThreadsCount < mProcess->mMaxThreads && mProcess->mStarvationStartTimeMs != 0) { int64_t starvationTimeMs = uptimeMillis() - mProcess->mStarvationStartTimeMs; if (starvationTimeMs > 100) { ALOGE("binder thread pool (%zu threads) starved for %" PRId64 " ms", mProcess->mMaxThreads, starvationTimeMs); } mProcess->mStarvationStartTimeMs = 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 @@ -343,6 +343,7 @@ ProcessState::ProcessState() , mThreadCountDecrement(PTHREAD_COND_INITIALIZER) , mExecutingThreadsCount(0) , mMaxThreads(DEFAULT_MAX_BINDER_THREADS) , mStarvationStartTimeMs(0) , mManagesContexts(false) , mBinderContextCheckFunc(NULL) , mBinderContextUserData(NULL) Loading