2
* Copyright (C) 2007 The Android Open Source Project
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
17
#ifndef _LIBS_UTILS_THREAD_DEFS_H
18
#define _LIBS_UTILS_THREAD_DEFS_H
21
#include <sys/types.h>
22
#include <system/graphics.h>
24
// ---------------------------------------------------------------------------
31
typedef void* android_thread_id_t;
33
typedef int (*android_thread_func_t)(void*);
37
* ***********************************************
38
* ** Keep in sync with android.os.Process.java **
39
* ***********************************************
41
* This maps directly to the "nice" priorities we use in Android.
42
* A thread priority should be chosen inverse-proportionally to
43
* the amount of work the thread is expected to do. The more work
44
* a thread will do, the less favorable priority it should get so that
45
* it doesn't starve the system. Threads not behaving properly might
46
* be "punished" by the kernel.
47
* Use the levels below when appropriate. Intermediate values are
48
* acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below.
50
ANDROID_PRIORITY_LOWEST = 19,
52
/* use for background tasks */
53
ANDROID_PRIORITY_BACKGROUND = 10,
55
/* most threads run at normal priority */
56
ANDROID_PRIORITY_NORMAL = 0,
58
/* threads currently running a UI that the user is interacting with */
59
ANDROID_PRIORITY_FOREGROUND = -2,
61
/* the main UI thread has a slightly more favorable priority */
62
ANDROID_PRIORITY_DISPLAY = -4,
64
/* ui service treads might want to run at a urgent display (uncommon) */
65
ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY,
67
/* all normal audio threads */
68
ANDROID_PRIORITY_AUDIO = -16,
70
/* service audio threads (uncommon) */
71
ANDROID_PRIORITY_URGENT_AUDIO = -19,
73
/* should never be used in practice. regular process might not
74
* be allowed to use this level */
75
ANDROID_PRIORITY_HIGHEST = -20,
77
ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL,
78
ANDROID_PRIORITY_MORE_FAVORABLE = -1,
79
ANDROID_PRIORITY_LESS_FAVORABLE = +1
86
// ---------------------------------------------------------------------------
90
// ---------------------------------------------------------------------------
92
typedef android_thread_id_t thread_id_t;
93
typedef android_thread_func_t thread_func_t;
96
PRIORITY_LOWEST = ANDROID_PRIORITY_LOWEST,
97
PRIORITY_BACKGROUND = ANDROID_PRIORITY_BACKGROUND,
98
PRIORITY_NORMAL = ANDROID_PRIORITY_NORMAL,
99
PRIORITY_FOREGROUND = ANDROID_PRIORITY_FOREGROUND,
100
PRIORITY_DISPLAY = ANDROID_PRIORITY_DISPLAY,
101
PRIORITY_URGENT_DISPLAY = ANDROID_PRIORITY_URGENT_DISPLAY,
102
PRIORITY_AUDIO = ANDROID_PRIORITY_AUDIO,
103
PRIORITY_URGENT_AUDIO = ANDROID_PRIORITY_URGENT_AUDIO,
104
PRIORITY_HIGHEST = ANDROID_PRIORITY_HIGHEST,
105
PRIORITY_DEFAULT = ANDROID_PRIORITY_DEFAULT,
106
PRIORITY_MORE_FAVORABLE = ANDROID_PRIORITY_MORE_FAVORABLE,
107
PRIORITY_LESS_FAVORABLE = ANDROID_PRIORITY_LESS_FAVORABLE
110
// ---------------------------------------------------------------------------
111
} // namespace android
112
#endif // __cplusplus
113
// ---------------------------------------------------------------------------
116
#endif // _LIBS_UTILS_THREAD_DEFS_H