Linux 有谁知道'top'命令的结果在android中的含义吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10051152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does any one know the 'top' command 's result's meaning in android?
提问by Hao Shen
I have found the result of 'top' is different from result of in standard linux.I have searched on the web a little bit but I can not find my answer. For example, following is the partial result of top in my android:
我发现 'top' 的结果与标准 linux 中的结果不同。我在网上搜索了一点,但找不到我的答案。例如,以下是我的 android 中 top 的部分结果:
PID CPU% S #THR VSS RSS PCY UID Name
814 2% R 1 940K 372K fg root top
110 1% S 58 185000K 59216K fg system system_server
31 0% S 1 0K 0K fg root vsync_workqueue
49 0% S 1 0K 0K fg root file-storage
52 0% S 1 0K 0K fg root gp2a_wq
178 0% S 9 98476K 23820K fg system com.android.systemui
So #THR probably is the number of threads.But what is 'PCY'? I can not find this information in the /proc/(PID)/ folder. And I have found that if I open an youtube, the PCY will be fg. Then if I quit it(youtube), the youtube process still exists but the PCY will be bg. And in terms of 'S', I have found all processes are always 'S' which means sleeping, even my youtube app is currently active. It's weired...
所以#THR 可能是线程数。但什么是“PCY”?我在 /proc/(PID)/ 文件夹中找不到此信息。我发现如果我打开一个 youtube,PCY 将是 fg。然后,如果我退出它(youtube),youtube 进程仍然存在,但 PCY 将是 bg。就“S”而言,我发现所有进程总是“S”,这意味着睡眠,即使我的 youtube 应用程序当前处于活动状态。怪怪的...
Does anyone have any clue:> Thx
有没有人有任何线索:> Thx
采纳答案by Ross Aiken
Here's my (un)educated guesses:
这是我的(未)受过教育的猜测:
PID - Process ID
PID - 进程 ID
CPU% - CPU Usage
CPU% - CPU 使用率
S - State (or possibly status) R=Running, S=Sleeping
S - 状态(或可能的状态)R=Running,S=Sleeping
#THR - Number of threads
#THR - 线程数
PCY - I'm kinda stumped here. You seem to have a pretty good grasp of what it does, so that's good enough (assuming that fg and bg are the only possible values)
PCY - 我有点难住这里。您似乎对它的作用非常了解,所以这就足够了(假设 fg 和 bg 是唯一可能的值)
UID - Name of the user that started the task
UID - 启动任务的用户名
Name - This one is self-explanatory...
名称 - 这是不言自明的...
VSS and RSS: From http://groups.google.com/group/android-beginners/browse_thread/thread/e6f2d396a68238ad?pli=1
VSS 和 RSS:来自http://groups.google.com/group/android-beginners/browse_thread/thread/e6f2d396a68238ad?pli=1
Virtual Set Size (sometimes abbreviated VSZ) and Resident Set Size. Googling will turn up some detailed info for Linux. Here's the high speed version:
虚拟集大小(有时缩写为 VSZ)和驻留集大小。谷歌搜索会找到一些 Linux 的详细信息。这是高速版本:
VSS indicates how much virtual memory is associated with the process, Resident Set Size indicates how many physical pages are associated with the process.
VSS 表示有多少虚拟内存与进程关联,Resident Set Size 表示有多少物理页面与进程关联。
VSS is generally meaningless on Android. If I memory-map a 1MB file, VSS grows by 1MB, but I haven't used any resources (other than entries in a virtual mapping table).
VSS 在 Android 上一般是没有意义的。如果我对 1MB 文件进行内存映射,VSS 会增长 1MB,但我没有使用任何资源(除了虚拟映射表中的条目)。
RSS is partially meaningless on Android, because it doesn't identify pages shared between multiple processes. If process A has an RSS of 2MB, and process B has an RSS of 2MB, it's possible that there are 4MB of physical pages occupied. It's also possible that there are only 2MB of physical pages occupied.
RSS 在 Android 上部分没有意义,因为它不识别多个进程之间共享的页面。如果进程 A 的 RSS 为 2MB,进程 B 的 RSS 为 2MB,则可能有 4MB 的物理页面被占用。也有可能只有 2MB 的物理页面被占用。
EDIT: As far as your Youtube is sleeping deal, if it isn't actively doing anything, it will be sleeping, even if it is in the foreground. Try creating a simple app that is basically while(1){Do something meaningless} and see if it is sleeping or running. Granted it also might be a quirk with the way that Android handles multitasking.
编辑:就您的 Youtube 处于休眠状态而言,如果它没有主动做任何事情,它就会处于休眠状态,即使它在前台也是如此。尝试创建一个简单的应用程序,它基本上是 while(1){做一些没有意义的事情},看看它是在睡觉还是在运行。当然,它也可能是 Android 处理多任务处理方式的一个怪癖。
EDIT2:
Mostly-uneducated-somewhat-random-stab-in-the-dark for PCY --
PCY -- Policy -- Determines how an app should be treated by Android's memory manager
FG -- Foreground -- Process is considered a foreground process and should not be killed to free mmemory
BG -- Background -- Process is considered a background process (not actively running in foreground and may be killed to free memory)
EDIT2:
PCY -
PCY - 策略 - 确定应用程序应如何被 Android 的内存管理器
FG - 前台 - 进程被视为前台进程并且不应该被杀死以释放内存
BG -- 后台 -- 进程被认为是后台进程(不在前台积极运行,可能会被杀死以释放内存)
回答by John Carter
Try man top
on any normal linux / unix (though I don't think Android has man installed by default).
man top
在任何普通的 linux/unix 上尝试(尽管我认为 Android 默认没有安装 man)。
Actually now I look it looks like those column titles aren't mentioned on that man
page, but the point stands that man
is usually the best place to start looking for information about linux / unix commands.
实际上,现在我看起来man
该页面上似乎没有提到这些列标题,但重点man
通常是开始查找有关 linux / unix 命令的信息的最佳位置。
回答by evan
top sourcecode [ top sourcecode][1]
顶级源代码 [ 顶级源代码][1]
[1]: http://androidxref.com/4.0.4/xref/system/core/toolbox/top.c#442to get the complete logic of how each value is calculated
[1]:http: //androidxref.com/4.0.4/xref/system/core/toolbox/top.c#442获取如何计算每个值的完整逻辑