summaryrefslogtreecommitdiffstats
path: root/libcutils
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2014-04-22 18:55:08 -0700
committerRuchi Kandoi <kandoiruchi@google.com>2014-04-23 21:56:40 +0000
commit422852ef5c0c2b0b5e031f80f480486df3d185a0 (patch)
treeee01f2e3a2ee1b947500ddb560c6986bce00cd95 /libcutils
parent00b8972062fb32dd02bcac7821a6612ce27ebd86 (diff)
downloadsystem_core-422852ef5c0c2b0b5e031f80f480486df3d185a0.zip
system_core-422852ef5c0c2b0b5e031f80f480486df3d185a0.tar.gz
system_core-422852ef5c0c2b0b5e031f80f480486df3d185a0.tar.bz2
Set timer slack value according to thread foreground/background state.
Change-Id: Ia998f349129acf4602b767d1ff94839607fdbdbd Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Diffstat (limited to 'libcutils')
-rw-r--r--libcutils/sched_policy.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c
index d20d217..bc49e88 100644
--- a/libcutils/sched_policy.c
+++ b/libcutils/sched_policy.c
@@ -26,6 +26,7 @@
#include <fcntl.h>
#include <cutils/sched_policy.h>
#include <cutils/log.h>
+#include <linux/prctl.h>
/* Re-map SP_DEFAULT to the system default policy, and leave other values unchanged.
* Call this any place a SchedPolicy is used as an input parameter.
@@ -53,6 +54,9 @@ static inline SchedPolicy _policy(SchedPolicy p)
#define CAN_SET_SP_SYSTEM 0 // non-zero means to implement set_sched_policy(tid, SP_SYSTEM)
+// timer slack value in nS enforced when the thread moves to background
+#define TIMER_SLACK_BG 40000000
+
static pthread_once_t the_once = PTHREAD_ONCE_INIT;
static int __sys_supports_schedgroups = -1;
@@ -324,6 +328,8 @@ int set_sched_policy(int tid, SchedPolicy policy)
&param);
}
+ prctl(PR_SET_TIMERSLACK_PID, policy == SP_BACKGROUND ? TIMER_SLACK_BG : 0, tid);
+
return 0;
}