summaryrefslogtreecommitdiffstats
path: root/libs/utils
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-09-09 23:11:22 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-09 23:11:22 -0700
commit84d10ad4294d6da4ce8e434100fc1f130f5a07de (patch)
tree8d34d4e56fa260f533a00d65a9e68ae504951f98 /libs/utils
parent203e9529c5d9a883088cc28439e003106397d6a4 (diff)
parent510951e98bdb861130f38c087956cd05e0b41dcd (diff)
downloadframeworks_base-84d10ad4294d6da4ce8e434100fc1f130f5a07de.zip
frameworks_base-84d10ad4294d6da4ce8e434100fc1f130f5a07de.tar.gz
frameworks_base-84d10ad4294d6da4ce8e434100fc1f130f5a07de.tar.bz2
am 510951e9: am a8512a71: Always set the scheduling group when starting a new thread.
Merge commit '510951e98bdb861130f38c087956cd05e0b41dcd' * commit '510951e98bdb861130f38c087956cd05e0b41dcd': Always set the scheduling group when starting a new thread.
Diffstat (limited to 'libs/utils')
-rw-r--r--libs/utils/Threads.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp
index e5ece8e..f6c55e4 100644
--- a/libs/utils/Threads.cpp
+++ b/libs/utils/Threads.cpp
@@ -65,6 +65,20 @@ 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;
@@ -80,6 +94,15 @@ 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 {
+ set_sched_policy(androidGetTid(), SP_FOREGROUND);
+ }
+ }
+
if (name) {
#if defined(HAVE_PRCTL)
// Mac OS doesn't have this, and we build libutil for the host too
@@ -281,22 +304,6 @@ pid_t androidGetTid()
#endif
}
-#if defined(HAVE_PTHREADS)
-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;
- }
- }
-}
-#endif
-
int androidSetThreadSchedulingGroup(pid_t tid, int grp)
{
if (grp > ANDROID_TGROUP_MAX || grp < 0) {