diff options
author | Ruchi Kandoi | 2014-04-22 20:55:08 -0500 |
---|---|---|
committer | Ruchi Kandoi | 2014-04-23 16:56:40 -0500 |
commit | 422852ef5c0c2b0b5e031f80f480486df3d185a0 (patch) | |
tree | ee01f2e3a2ee1b947500ddb560c6986bce00cd95 /libcutils/sched_policy.c | |
parent | 00b8972062fb32dd02bcac7821a6612ce27ebd86 (diff) | |
download | platform-system-core-422852ef5c0c2b0b5e031f80f480486df3d185a0.tar.gz platform-system-core-422852ef5c0c2b0b5e031f80f480486df3d185a0.tar.xz platform-system-core-422852ef5c0c2b0b5e031f80f480486df3d185a0.zip |
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/sched_policy.c')
-rw-r--r-- | libcutils/sched_policy.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c index d20d217b7..bc49e8841 100644 --- a/libcutils/sched_policy.c +++ b/libcutils/sched_policy.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <fcntl.h> | 26 | #include <fcntl.h> |
27 | #include <cutils/sched_policy.h> | 27 | #include <cutils/sched_policy.h> |
28 | #include <cutils/log.h> | 28 | #include <cutils/log.h> |
29 | #include <linux/prctl.h> | ||
29 | 30 | ||
30 | /* Re-map SP_DEFAULT to the system default policy, and leave other values unchanged. | 31 | /* Re-map SP_DEFAULT to the system default policy, and leave other values unchanged. |
31 | * Call this any place a SchedPolicy is used as an input parameter. | 32 | * Call this any place a SchedPolicy is used as an input parameter. |
@@ -53,6 +54,9 @@ static inline SchedPolicy _policy(SchedPolicy p) | |||
53 | 54 | ||
54 | #define CAN_SET_SP_SYSTEM 0 // non-zero means to implement set_sched_policy(tid, SP_SYSTEM) | 55 | #define CAN_SET_SP_SYSTEM 0 // non-zero means to implement set_sched_policy(tid, SP_SYSTEM) |
55 | 56 | ||
57 | // timer slack value in nS enforced when the thread moves to background | ||
58 | #define TIMER_SLACK_BG 40000000 | ||
59 | |||
56 | static pthread_once_t the_once = PTHREAD_ONCE_INIT; | 60 | static pthread_once_t the_once = PTHREAD_ONCE_INIT; |
57 | 61 | ||
58 | static int __sys_supports_schedgroups = -1; | 62 | static int __sys_supports_schedgroups = -1; |
@@ -324,6 +328,8 @@ int set_sched_policy(int tid, SchedPolicy policy) | |||
324 | ¶m); | 328 | ¶m); |
325 | } | 329 | } |
326 | 330 | ||
331 | prctl(PR_SET_TIMERSLACK_PID, policy == SP_BACKGROUND ? TIMER_SLACK_BG : 0, tid); | ||
332 | |||
327 | return 0; | 333 | return 0; |
328 | } | 334 | } |
329 | 335 | ||