Loading services/surfaceflinger/main_surfaceflinger.cpp +34 −0 Original line number Diff line number Diff line Loading @@ -89,13 +89,47 @@ int main(int, char**) { // binder threads to 4. ProcessState::self()->setThreadPoolMaxThreadCount(4); // The binder threadpool we start will inherit sched policy and priority // of (this) creating thread. We want the binder thread pool to have // SCHED_FIFO policy and priority 1 (lowest RT priority) // Once the pool is created we reset this thread's priority back to // original. int newPriority = 0; int origPolicy = sched_getscheduler(0); struct sched_param origSchedParam; int errorInPriorityModification = sched_getparam(0, &origSchedParam); if (errorInPriorityModification == 0) { int policy = SCHED_FIFO; newPriority = sched_get_priority_min(policy); struct sched_param param; param.sched_priority = newPriority; errorInPriorityModification = sched_setscheduler(0, policy, ¶m); } // start the thread pool sp<ProcessState> ps(ProcessState::self()); ps->startThreadPool(); // Reset current thread's policy and priority if (errorInPriorityModification == 0) { errorInPriorityModification = sched_setscheduler(0, origPolicy, &origSchedParam); } else { ALOGE("Failed to set SurfaceFlinger binder threadpool priority to SCHED_FIFO"); } // instantiate surfaceflinger sp<SurfaceFlinger> flinger = surfaceflinger::createSurfaceFlinger(); // Set the minimum policy of surfaceflinger node to be SCHED_FIFO. // So any thread with policy/priority lower than {SCHED_FIFO, 1}, will run // at least with SCHED_FIFO policy and priority 1. if (errorInPriorityModification == 0) { flinger->setMinSchedulerPolicy(SCHED_FIFO, newPriority); } setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_DISPLAY); set_sched_policy(0, SP_FOREGROUND); Loading Loading
services/surfaceflinger/main_surfaceflinger.cpp +34 −0 Original line number Diff line number Diff line Loading @@ -89,13 +89,47 @@ int main(int, char**) { // binder threads to 4. ProcessState::self()->setThreadPoolMaxThreadCount(4); // The binder threadpool we start will inherit sched policy and priority // of (this) creating thread. We want the binder thread pool to have // SCHED_FIFO policy and priority 1 (lowest RT priority) // Once the pool is created we reset this thread's priority back to // original. int newPriority = 0; int origPolicy = sched_getscheduler(0); struct sched_param origSchedParam; int errorInPriorityModification = sched_getparam(0, &origSchedParam); if (errorInPriorityModification == 0) { int policy = SCHED_FIFO; newPriority = sched_get_priority_min(policy); struct sched_param param; param.sched_priority = newPriority; errorInPriorityModification = sched_setscheduler(0, policy, ¶m); } // start the thread pool sp<ProcessState> ps(ProcessState::self()); ps->startThreadPool(); // Reset current thread's policy and priority if (errorInPriorityModification == 0) { errorInPriorityModification = sched_setscheduler(0, origPolicy, &origSchedParam); } else { ALOGE("Failed to set SurfaceFlinger binder threadpool priority to SCHED_FIFO"); } // instantiate surfaceflinger sp<SurfaceFlinger> flinger = surfaceflinger::createSurfaceFlinger(); // Set the minimum policy of surfaceflinger node to be SCHED_FIFO. // So any thread with policy/priority lower than {SCHED_FIFO, 1}, will run // at least with SCHED_FIFO policy and priority 1. if (errorInPriorityModification == 0) { flinger->setMinSchedulerPolicy(SCHED_FIFO, newPriority); } setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_DISPLAY); set_sched_policy(0, SP_FOREGROUND); Loading