From: Mathias Agopian Date: Fri, 23 Aug 2013 22:56:38 +0000 (-0700) Subject: make sure SF initialization is ran at target priority and correct thread group X-Git-Tag: android-x86-4.4-r1~80^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9414d67f46d315873502b909ee51bab7abf3f9cc;p=android-x86%2Fframeworks-native.git make sure SF initialization is ran at target priority and correct thread group SF can spawn threads (indirectly) during initialization and we want those to be spawned at URGENT_DISPLAY_PRIORITY (in theory they should set their own, but some code lives in vendor libraries and doesn't). Bug: 10430209 Change-Id: I5b3a8f979297de287614c8eafd8267bef1176e4b --- diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 81b0d14b05..3888d7e54a 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -82,6 +82,7 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libsurfaceflinger \ + libcutils \ liblog \ libbinder \ libutils diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index a15114213a..9fd3f25fe2 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -22,10 +22,6 @@ #include #include -#if defined(HAVE_PTHREADS) -#include -#endif - #include #include @@ -640,9 +636,6 @@ status_t SurfaceFlinger::postMessageSync(const sp& msg, } void SurfaceFlinger::run() { -#if defined(HAVE_PTHREADS) - setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_DISPLAY); -#endif do { waitForEvent(); } while (true); diff --git a/services/surfaceflinger/main_surfaceflinger.cpp b/services/surfaceflinger/main_surfaceflinger.cpp index a609b6fd48..b161480b3e 100644 --- a/services/surfaceflinger/main_surfaceflinger.cpp +++ b/services/surfaceflinger/main_surfaceflinger.cpp @@ -14,6 +14,11 @@ * limitations under the License. */ +#if defined(HAVE_PTHREADS) +#include +#endif + +#include #include #include #include @@ -27,16 +32,21 @@ int main(int argc, char** argv) { // binder threads to 4. ProcessState::self()->setThreadPoolMaxThreadCount(4); + // start the thread pool + sp ps(ProcessState::self()); + ps->startThreadPool(); + // instantiate surfaceflinger sp flinger = new SurfaceFlinger(); +#if defined(HAVE_PTHREADS) + setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_DISPLAY); +#endif + set_sched_policy(0, SP_FOREGROUND); + // initialize before clients can connect flinger->init(); - // start the thread pool - sp ps(ProcessState::self()); - ps->startThreadPool(); - // publish surface flinger sp sm(defaultServiceManager()); sm->addService(String16(SurfaceFlinger::getServiceName()), flinger, false);