diff options
author | Glenn Kasten <gkasten@google.com> | 2012-04-30 16:03:30 -0700 |
---|---|---|
committer | Alex Ray <aray@google.com> | 2013-07-30 13:57:00 -0700 |
commit | fe34e45c217e67e32fa56b7e01fd4163a621c647 (patch) | |
tree | 1635e289020fd98874604241920af541df218f42 /libs | |
parent | 61db1669f491b221411269f62bd1cb458a543181 (diff) | |
download | core-fe34e45c217e67e32fa56b7e01fd4163a621c647.tar.gz core-fe34e45c217e67e32fa56b7e01fd4163a621c647.tar.bz2 core-fe34e45c217e67e32fa56b7e01fd4163a621c647.zip |
Continue removing property debug.sys.noschedgroups
Also 0 means gettid() for get_sched_policy() and set_sched_policy().
Change-Id: Ic12edc3df6c9b3e99eae5cffaf9f6fe56cf14043
Diffstat (limited to 'libs')
-rw-r--r-- | libs/utils/Threads.cpp | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp index a25a81fbe..f201fc744 100644 --- a/libs/utils/Threads.cpp +++ b/libs/utils/Threads.cpp @@ -68,20 +68,6 @@ using namespace android; typedef void* (*android_pthread_entry)(void*); -static pthread_once_t gDoSchedulingGroupOnce = PTHREAD_ONCE_INIT; -static bool gDoSchedulingGroup = true; - -static void checkDoSchedulingGroup(void) { - char buf[PROPERTY_VALUE_MAX]; - int len = property_get("debug.sys.noschedgroups", buf, ""); - if (len > 0) { - int temp; - if (sscanf(buf, "%d", &temp) == 1) { - gDoSchedulingGroup = temp == 0; - } - } -} - struct thread_data_t { thread_func_t entryFunction; void* userData; @@ -97,15 +83,10 @@ struct thread_data_t { char * name = t->threadName; delete t; setpriority(PRIO_PROCESS, 0, prio); - pthread_once(&gDoSchedulingGroupOnce, checkDoSchedulingGroup); - if (gDoSchedulingGroup) { - if (prio >= ANDROID_PRIORITY_BACKGROUND) { - set_sched_policy(androidGetTid(), SP_BACKGROUND); - } else if (prio > ANDROID_PRIORITY_AUDIO) { - set_sched_policy(androidGetTid(), SP_FOREGROUND); - } else { - // defaults to that of parent, or as set by requestPriority() - } + if (prio >= ANDROID_PRIORITY_BACKGROUND) { + set_sched_policy(0, SP_BACKGROUND); + } else { + set_sched_policy(0, SP_FOREGROUND); } if (name) { @@ -333,20 +314,10 @@ int androidSetThreadPriority(pid_t tid, int pri) #if defined(HAVE_PTHREADS) int lasterr = 0; - pthread_once(&gDoSchedulingGroupOnce, checkDoSchedulingGroup); - if (gDoSchedulingGroup) { - // set_sched_policy does not support tid == 0 - int policy_tid; - if (tid == 0) { - policy_tid = androidGetTid(); - } else { - policy_tid = tid; - } - if (pri >= ANDROID_PRIORITY_BACKGROUND) { - rc = set_sched_policy(policy_tid, SP_BACKGROUND); - } else if (getpriority(PRIO_PROCESS, tid) >= ANDROID_PRIORITY_BACKGROUND) { - rc = set_sched_policy(policy_tid, SP_FOREGROUND); - } + if (pri >= ANDROID_PRIORITY_BACKGROUND) { + rc = set_sched_policy(tid, SP_BACKGROUND); + } else if (getpriority(PRIO_PROCESS, tid) >= ANDROID_PRIORITY_BACKGROUND) { + rc = set_sched_policy(tid, SP_FOREGROUND); } if (rc) { |