blob: c6e4fc444e3574abbc444a49ce8092f869d36d72 [file] [log] [blame]
San Mehat493dad92009-09-12 10:06:57 -07001/*
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
21extern "C" {
22#endif
23
Glenn Kasten69bfb1f2012-03-16 09:43:19 -070024/* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */
San Mehat493dad92009-09-12 10:06:57 -070025typedef enum {
Glenn Kasten69bfb1f2012-03-16 09:43:19 -070026 SP_DEFAULT = -1,
San Mehat493dad92009-09-12 10:06:57 -070027 SP_BACKGROUND = 0,
28 SP_FOREGROUND = 1,
Glenn Kasten86c7cc82012-03-05 16:14:39 -080029 SP_CNT,
30 SP_MAX = SP_CNT - 1,
Glenn Kasten69bfb1f2012-03-16 09:43:19 -070031 SP_SYSTEM_DEFAULT = SP_FOREGROUND,
San Mehat493dad92009-09-12 10:06:57 -070032} SchedPolicy;
33
Glenn Kasten86c7cc82012-03-05 16:14:39 -080034/* Assign thread tid to the cgroup associated with the specified policy.
35 * If the thread is a thread group leader, that is it's gettid() == getpid(),
36 * then the other threads in the same thread group are _not_ affected.
Glenn Kasten69bfb1f2012-03-16 09:43:19 -070037 * On platforms which support gettid(), zero tid means current thread.
Glenn Kasten86c7cc82012-03-05 16:14:39 -080038 * Return value: 0 for success, or -errno for error.
39 */
San Mehat493dad92009-09-12 10:06:57 -070040extern int set_sched_policy(int tid, SchedPolicy policy);
Glenn Kasten86c7cc82012-03-05 16:14:39 -080041
42/* Return the policy associated with the cgroup of thread tid via policy pointer.
Glenn Kasten69bfb1f2012-03-16 09:43:19 -070043 * On platforms which support gettid(), zero tid means current thread.
Glenn Kasten86c7cc82012-03-05 16:14:39 -080044 * Return value: 0 for success, or -1 for error and set errno.
45 */
San Mehatc0dfca72009-10-27 11:52:55 -070046extern int get_sched_policy(int tid, SchedPolicy *policy);
San Mehat493dad92009-09-12 10:06:57 -070047
Glenn Kasten86c7cc82012-03-05 16:14:39 -080048/* Return a displayable string corresponding to policy.
49 * Return value: non-NULL NUL-terminated name of unspecified length;
50 * the caller is responsible for displaying the useful part of the string.
51 */
52extern const char *get_sched_policy_name(SchedPolicy policy);
53
San Mehat493dad92009-09-12 10:06:57 -070054#ifdef __cplusplus
55}
56#endif
57
58#endif /* __CUTILS_SCHED_POLICY_H */