Android??????????????
???????????? ???????[ 2014/3/18 15:23:32 ] ????????Android ????
????????????????MediaProvider?????????????????????????????????????????
???????Pad???к??y????????????ο???????????????Home Screen??????????????????????ANR???????ANR???/data/anr/traces.txt?????????????????cpu??????У?android.process.media??÷??????????????MediaProvider???????????CPU???????????
?????????????????????????top –m 5??cpu????????????????????Home??android.process.media????cpu????????????
?????????????????????о???MediaProvider???CPU????????????????????????????????????????????????????????????????е?????y??????????????
????????????????????????????????????????MediaScannerService?У????????
public void run????
{
Process.setThreadPriority??Process.THREAD_PRIORITY_BACKGROUND +
Process.THREAD_PRIORITY_LESS_FAVORABLE??;
……
}
???????????????y??????????????????BACKGROUND+LESS_FAVORABLE??
??????????????????????
?????????????????????
?????? Android?????????????????????
?????? ?????????????Linux OS???????????????????????Linux OS?е???????????????
????????Android???е?????????
?????????Java????Anroid????Process????????????????????????????ЩAPI?????????????????????????λ?á?
?????????????????
?????? ???????Process.java????setThreadPriority??setThreadGroup??????
?????? ???÷??????Java????JNI??Native???setThreadPriority???????setpriority?????????setThreadGroup???set_sched_policy???????????sched_setscheduler?????á?
????2.1 ????????????
????????????????????????ò?????????????
????OS????????????????????????????????????????CPU??????????????????????????CPU?????????????????????????????η??????OS?????
???????????????androidSetThreadPriority??????
int androidSetThreadPriority??pid_t tid?? int pri??
{
??if defined??HAVE_PTHREADS?? //???????POSIX
//phtread_once????????????????????????Σ???????Class??constructor??
//checkDoSchedulingGroup???????ú????ж????????????”debug.sys.noschedgroups”
pthread_once??&gDoSchedulingGroupOnce?? checkDoSchedulingGroup??;
if ??gDoSchedulingGroup?? {
if ??pri >= ANDROID_PRIORITY_BACKGROUND?? {
//????????????????????????????
rc = set_sched_policy??tid?? SP_BACKGROUND??;
} else if ??getpriority??PRIO_PROCESS?? tid?? >= ANDROID_PRIORITY_BACKGROUND?? {
rc = set_sched_policy??tid?? SP_FOREGROUND??;
}
}
……
//??????????????
if ??setpriority??PRIO_PROCESS?? tid?? pri?? < 0?? {
rc = INVALID_OPERATION;
}
……
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11