1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (C) 2013 The Android Open Source Project 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 5bf215546Sopenharmony_ci * you may not use this file except in compliance with the License. 6bf215546Sopenharmony_ci * You may obtain a copy of the License at 7bf215546Sopenharmony_ci * 8bf215546Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 9bf215546Sopenharmony_ci * 10bf215546Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 11bf215546Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 12bf215546Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13bf215546Sopenharmony_ci * See the License for the specific language governing permissions and 14bf215546Sopenharmony_ci * limitations under the License. 15bf215546Sopenharmony_ci */ 16bf215546Sopenharmony_ci 17bf215546Sopenharmony_ci#ifndef ANDROID_THREAD_DEFS_H 18bf215546Sopenharmony_ci#define ANDROID_THREAD_DEFS_H 19bf215546Sopenharmony_ci 20bf215546Sopenharmony_ci#include "graphics.h" 21bf215546Sopenharmony_ci 22bf215546Sopenharmony_ci#if defined(__cplusplus) 23bf215546Sopenharmony_ciextern "C" { 24bf215546Sopenharmony_ci#endif 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_cienum { 27bf215546Sopenharmony_ci /* 28bf215546Sopenharmony_ci * *********************************************** 29bf215546Sopenharmony_ci * ** Keep in sync with android.os.Process.java ** 30bf215546Sopenharmony_ci * *********************************************** 31bf215546Sopenharmony_ci * 32bf215546Sopenharmony_ci * This maps directly to the "nice" priorities we use in Android. 33bf215546Sopenharmony_ci * A thread priority should be chosen inverse-proportionally to 34bf215546Sopenharmony_ci * the amount of work the thread is expected to do. The more work 35bf215546Sopenharmony_ci * a thread will do, the less favorable priority it should get so that 36bf215546Sopenharmony_ci * it doesn't starve the system. Threads not behaving properly might 37bf215546Sopenharmony_ci * be "punished" by the kernel. 38bf215546Sopenharmony_ci * Use the levels below when appropriate. Intermediate values are 39bf215546Sopenharmony_ci * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below. 40bf215546Sopenharmony_ci */ 41bf215546Sopenharmony_ci ANDROID_PRIORITY_LOWEST = 19, 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_ci /* use for background tasks */ 44bf215546Sopenharmony_ci ANDROID_PRIORITY_BACKGROUND = 10, 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci /* most threads run at normal priority */ 47bf215546Sopenharmony_ci ANDROID_PRIORITY_NORMAL = 0, 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci /* threads currently running a UI that the user is interacting with */ 50bf215546Sopenharmony_ci ANDROID_PRIORITY_FOREGROUND = -2, 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_ci /* the main UI thread has a slightly more favorable priority */ 53bf215546Sopenharmony_ci ANDROID_PRIORITY_DISPLAY = -4, 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci /* ui service treads might want to run at a urgent display (uncommon) */ 56bf215546Sopenharmony_ci ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY, 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci /* all normal video threads */ 59bf215546Sopenharmony_ci ANDROID_PRIORITY_VIDEO = -10, 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_ci /* all normal audio threads */ 62bf215546Sopenharmony_ci ANDROID_PRIORITY_AUDIO = -16, 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci /* service audio threads (uncommon) */ 65bf215546Sopenharmony_ci ANDROID_PRIORITY_URGENT_AUDIO = -19, 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_ci /* should never be used in practice. regular process might not 68bf215546Sopenharmony_ci * be allowed to use this level */ 69bf215546Sopenharmony_ci ANDROID_PRIORITY_HIGHEST = -20, 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL, 72bf215546Sopenharmony_ci ANDROID_PRIORITY_MORE_FAVORABLE = -1, 73bf215546Sopenharmony_ci ANDROID_PRIORITY_LESS_FAVORABLE = +1, 74bf215546Sopenharmony_ci}; 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_ci#if defined(__cplusplus) 77bf215546Sopenharmony_ci} 78bf215546Sopenharmony_ci#endif 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci#endif /* ANDROID_THREAD_DEFS_H */ 81