blob: 377a48ce922f93bef69b2640e1557843c2a433ce [file] [log] [blame]
Alex Ray8a84c712013-07-23 17:04:24 -07001/*
2 * Copyright (C) 2013 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 ANDROID_THREAD_DEFS_H
18#define ANDROID_THREAD_DEFS_H
19
Alex Ray8a84c712013-07-23 17:04:24 -070020#include "graphics.h"
21
Colin Cross42cf2b52013-07-23 19:58:03 -070022#if defined(__cplusplus)
23extern "C" {
24#endif
Alex Ray8a84c712013-07-23 17:04:24 -070025
26enum {
27 /*
28 * ***********************************************
29 * ** Keep in sync with android.os.Process.java **
30 * ***********************************************
Alex Ray000b1d02013-07-23 22:20:45 -070031 *
Alex Ray8a84c712013-07-23 17:04:24 -070032 * This maps directly to the "nice" priorities we use in Android.
33 * A thread priority should be chosen inverse-proportionally to
34 * the amount of work the thread is expected to do. The more work
Alex Ray000b1d02013-07-23 22:20:45 -070035 * a thread will do, the less favorable priority it should get so that
Alex Ray8a84c712013-07-23 17:04:24 -070036 * it doesn't starve the system. Threads not behaving properly might
37 * be "punished" by the kernel.
38 * Use the levels below when appropriate. Intermediate values are
39 * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below.
40 */
41 ANDROID_PRIORITY_LOWEST = 19,
42
43 /* use for background tasks */
44 ANDROID_PRIORITY_BACKGROUND = 10,
Alex Ray000b1d02013-07-23 22:20:45 -070045
Alex Ray8a84c712013-07-23 17:04:24 -070046 /* most threads run at normal priority */
47 ANDROID_PRIORITY_NORMAL = 0,
Alex Ray000b1d02013-07-23 22:20:45 -070048
Alex Ray8a84c712013-07-23 17:04:24 -070049 /* threads currently running a UI that the user is interacting with */
50 ANDROID_PRIORITY_FOREGROUND = -2,
51
52 /* the main UI thread has a slightly more favorable priority */
53 ANDROID_PRIORITY_DISPLAY = -4,
Alex Ray000b1d02013-07-23 22:20:45 -070054
Alex Ray8a84c712013-07-23 17:04:24 -070055 /* ui service treads might want to run at a urgent display (uncommon) */
56 ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY,
Alex Ray000b1d02013-07-23 22:20:45 -070057
Alex Ray8a84c712013-07-23 17:04:24 -070058 /* all normal audio threads */
59 ANDROID_PRIORITY_AUDIO = -16,
Alex Ray000b1d02013-07-23 22:20:45 -070060
Alex Ray8a84c712013-07-23 17:04:24 -070061 /* service audio threads (uncommon) */
62 ANDROID_PRIORITY_URGENT_AUDIO = -19,
63
Alex Ray000b1d02013-07-23 22:20:45 -070064 /* should never be used in practice. regular process might not
Alex Ray8a84c712013-07-23 17:04:24 -070065 * be allowed to use this level */
66 ANDROID_PRIORITY_HIGHEST = -20,
67
68 ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL,
69 ANDROID_PRIORITY_MORE_FAVORABLE = -1,
70 ANDROID_PRIORITY_LESS_FAVORABLE = +1,
71};
72
Colin Cross42cf2b52013-07-23 19:58:03 -070073#if defined(__cplusplus)
74}
75#endif
Alex Ray8a84c712013-07-23 17:04:24 -070076
77#endif /* ANDROID_THREAD_DEFS_H */