San Mehat | 493dad9 | 2009-09-12 10:06:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __CUTILS_SCHED_POLICY_H |
| 18 | #define __CUTILS_SCHED_POLICY_H |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
Glenn Kasten | 69bfb1f | 2012-03-16 09:43:19 -0700 | [diff] [blame] | 24 | /* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ |
San Mehat | 493dad9 | 2009-09-12 10:06:57 -0700 | [diff] [blame] | 25 | typedef enum { |
Glenn Kasten | 69bfb1f | 2012-03-16 09:43:19 -0700 | [diff] [blame] | 26 | SP_DEFAULT = -1, |
San Mehat | 493dad9 | 2009-09-12 10:06:57 -0700 | [diff] [blame] | 27 | SP_BACKGROUND = 0, |
| 28 | SP_FOREGROUND = 1, |
Glenn Kasten | 10ec3c7 | 2012-04-19 15:25:58 -0700 | [diff] [blame] | 29 | SP_SYSTEM = 2, // can't be used with set_sched_policy() |
| 30 | SP_AUDIO_APP = 3, |
| 31 | SP_AUDIO_SYS = 4, |
Glenn Kasten | 86c7cc8 | 2012-03-05 16:14:39 -0800 | [diff] [blame] | 32 | SP_CNT, |
| 33 | SP_MAX = SP_CNT - 1, |
Glenn Kasten | 69bfb1f | 2012-03-16 09:43:19 -0700 | [diff] [blame] | 34 | SP_SYSTEM_DEFAULT = SP_FOREGROUND, |
San Mehat | 493dad9 | 2009-09-12 10:06:57 -0700 | [diff] [blame] | 35 | } SchedPolicy; |
| 36 | |
Tim Murray | b769c8d | 2015-06-08 14:56:29 -0700 | [diff] [blame] | 37 | extern int set_cpuset_policy(int tid, SchedPolicy policy); |
| 38 | |
Glenn Kasten | 86c7cc8 | 2012-03-05 16:14:39 -0800 | [diff] [blame] | 39 | /* Assign thread tid to the cgroup associated with the specified policy. |
| 40 | * If the thread is a thread group leader, that is it's gettid() == getpid(), |
| 41 | * then the other threads in the same thread group are _not_ affected. |
Glenn Kasten | 69bfb1f | 2012-03-16 09:43:19 -0700 | [diff] [blame] | 42 | * On platforms which support gettid(), zero tid means current thread. |
Glenn Kasten | 86c7cc8 | 2012-03-05 16:14:39 -0800 | [diff] [blame] | 43 | * Return value: 0 for success, or -errno for error. |
| 44 | */ |
San Mehat | 493dad9 | 2009-09-12 10:06:57 -0700 | [diff] [blame] | 45 | extern int set_sched_policy(int tid, SchedPolicy policy); |
Glenn Kasten | 86c7cc8 | 2012-03-05 16:14:39 -0800 | [diff] [blame] | 46 | |
| 47 | /* Return the policy associated with the cgroup of thread tid via policy pointer. |
Glenn Kasten | 69bfb1f | 2012-03-16 09:43:19 -0700 | [diff] [blame] | 48 | * On platforms which support gettid(), zero tid means current thread. |
Glenn Kasten | 86c7cc8 | 2012-03-05 16:14:39 -0800 | [diff] [blame] | 49 | * Return value: 0 for success, or -1 for error and set errno. |
| 50 | */ |
San Mehat | c0dfca7 | 2009-10-27 11:52:55 -0700 | [diff] [blame] | 51 | extern int get_sched_policy(int tid, SchedPolicy *policy); |
San Mehat | 493dad9 | 2009-09-12 10:06:57 -0700 | [diff] [blame] | 52 | |
Glenn Kasten | 86c7cc8 | 2012-03-05 16:14:39 -0800 | [diff] [blame] | 53 | /* Return a displayable string corresponding to policy. |
| 54 | * Return value: non-NULL NUL-terminated name of unspecified length; |
| 55 | * the caller is responsible for displaying the useful part of the string. |
| 56 | */ |
| 57 | extern const char *get_sched_policy_name(SchedPolicy policy); |
| 58 | |
San Mehat | 493dad9 | 2009-09-12 10:06:57 -0700 | [diff] [blame] | 59 | #ifdef __cplusplus |
| 60 | } |
| 61 | #endif |
| 62 | |
| 63 | #endif /* __CUTILS_SCHED_POLICY_H */ |