Loading cmds/surfaceflinger/main_surfaceflinger.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -20,9 +20,9 @@ using namespace android; int main(int argc, char** argv) { SurfaceFlinger::publishAndJoinThreadPool(true); // When SF is launched in its own process, limit the number of // binder threads to 4. ProcessState::self()->setThreadPoolMaxThreadCount(4); SurfaceFlinger::publishAndJoinThreadPool(true); return 0; } include/binder/BinderService.h +7 −2 Original line number Diff line number Diff line Loading @@ -36,13 +36,18 @@ class BinderService public: static status_t publish(bool allowIsolated = false) { sp<IServiceManager> sm(defaultServiceManager()); return sm->addService(String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); return sm->addService( String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); } static void publishAndJoinThreadPool(bool allowIsolated = false) { sp<IServiceManager> sm(defaultServiceManager()); sm->addService(String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); sm->addService( String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); ProcessState::self()->startThreadPool(); ProcessState::self()->giveThreadPoolName(); IPCThreadState::self()->joinThreadPool(); } Loading include/binder/ProcessState.h +2 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ public: void spawnPooledThread(bool isMain); status_t setThreadPoolMaxThreadCount(size_t maxThreads); void giveThreadPoolName(); private: friend class IPCThreadState; Loading @@ -80,6 +81,7 @@ private: ProcessState(const ProcessState& o); ProcessState& operator=(const ProcessState& o); String8 makeBinderThreadName(); struct handle_entry { IBinder* binder; Loading include/utils/AndroidThreads.h +3 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,9 @@ extern int androidCreateRawThreadEtc(android_thread_func_t entryFunction, size_t threadStackSize, android_thread_id_t *threadId); // set the same of the running thread extern void androidSetThreadName(const char* name); // Used by the Java Runtime to control how threads are created, so that // they can be proper and lovely Java threads. typedef int (*android_create_thread_fn)(android_thread_func_t entryFunction, Loading libs/binder/ProcessState.cpp +14 −5 Original line number Diff line number Diff line Loading @@ -283,15 +283,20 @@ void ProcessState::setArgV0(const char* txt) } } String8 ProcessState::makeBinderThreadName() { int32_t s = android_atomic_add(1, &mThreadPoolSeq); String8 name; name.appendFormat("Binder_%X", s); return name; } void ProcessState::spawnPooledThread(bool isMain) { if (mThreadPoolStarted) { int32_t s = android_atomic_add(1, &mThreadPoolSeq); char buf[16]; snprintf(buf, sizeof(buf), "Binder_%X", s); ALOGV("Spawning new pooled thread, name=%s\n", buf); String8 name = makeBinderThreadName(); ALOGV("Spawning new pooled thread, name=%s\n", name.string()); sp<Thread> t = new PoolThread(isMain); t->run(buf); t->run(name.string()); } } Loading @@ -304,6 +309,10 @@ status_t ProcessState::setThreadPoolMaxThreadCount(size_t maxThreads) { return result; } void ProcessState::giveThreadPoolName() { androidSetThreadName( makeBinderThreadName().string() ); } static int open_driver() { int fd = open("/dev/binder", O_RDWR); Loading Loading
cmds/surfaceflinger/main_surfaceflinger.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -20,9 +20,9 @@ using namespace android; int main(int argc, char** argv) { SurfaceFlinger::publishAndJoinThreadPool(true); // When SF is launched in its own process, limit the number of // binder threads to 4. ProcessState::self()->setThreadPoolMaxThreadCount(4); SurfaceFlinger::publishAndJoinThreadPool(true); return 0; }
include/binder/BinderService.h +7 −2 Original line number Diff line number Diff line Loading @@ -36,13 +36,18 @@ class BinderService public: static status_t publish(bool allowIsolated = false) { sp<IServiceManager> sm(defaultServiceManager()); return sm->addService(String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); return sm->addService( String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); } static void publishAndJoinThreadPool(bool allowIsolated = false) { sp<IServiceManager> sm(defaultServiceManager()); sm->addService(String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); sm->addService( String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); ProcessState::self()->startThreadPool(); ProcessState::self()->giveThreadPoolName(); IPCThreadState::self()->joinThreadPool(); } Loading
include/binder/ProcessState.h +2 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ public: void spawnPooledThread(bool isMain); status_t setThreadPoolMaxThreadCount(size_t maxThreads); void giveThreadPoolName(); private: friend class IPCThreadState; Loading @@ -80,6 +81,7 @@ private: ProcessState(const ProcessState& o); ProcessState& operator=(const ProcessState& o); String8 makeBinderThreadName(); struct handle_entry { IBinder* binder; Loading
include/utils/AndroidThreads.h +3 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,9 @@ extern int androidCreateRawThreadEtc(android_thread_func_t entryFunction, size_t threadStackSize, android_thread_id_t *threadId); // set the same of the running thread extern void androidSetThreadName(const char* name); // Used by the Java Runtime to control how threads are created, so that // they can be proper and lovely Java threads. typedef int (*android_create_thread_fn)(android_thread_func_t entryFunction, Loading
libs/binder/ProcessState.cpp +14 −5 Original line number Diff line number Diff line Loading @@ -283,15 +283,20 @@ void ProcessState::setArgV0(const char* txt) } } String8 ProcessState::makeBinderThreadName() { int32_t s = android_atomic_add(1, &mThreadPoolSeq); String8 name; name.appendFormat("Binder_%X", s); return name; } void ProcessState::spawnPooledThread(bool isMain) { if (mThreadPoolStarted) { int32_t s = android_atomic_add(1, &mThreadPoolSeq); char buf[16]; snprintf(buf, sizeof(buf), "Binder_%X", s); ALOGV("Spawning new pooled thread, name=%s\n", buf); String8 name = makeBinderThreadName(); ALOGV("Spawning new pooled thread, name=%s\n", name.string()); sp<Thread> t = new PoolThread(isMain); t->run(buf); t->run(name.string()); } } Loading @@ -304,6 +309,10 @@ status_t ProcessState::setThreadPoolMaxThreadCount(size_t maxThreads) { return result; } void ProcessState::giveThreadPoolName() { androidSetThreadName( makeBinderThreadName().string() ); } static int open_driver() { int fd = open("/dev/binder", O_RDWR); Loading