diff options
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 9f092d6..fa0792f 100644 --- a/libcutils/sched_policy.c +++ b/libcutils/sched_policy.c @@ -39,6 +39,7 @@ static inline SchedPolicy _policy(SchedPolicy p) #if defined(HAVE_ANDROID_OS) && defined(HAVE_SCHED_H) && defined(HAVE_PTHREADS) +#include <linux/prctl.h> #include <sched.h> #include <pthread.h> @@ -54,6 +55,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; @@ -325,6 +329,8 @@ int set_sched_policy(int tid, SchedPolicy policy) ¶m); } + prctl(PR_SET_TIMERSLACK_PID, policy == SP_BACKGROUND ? TIMER_SLACK_BG : 0, tid); + return 0; } |