熟习Top命令的朋友请进,另有1000分相赠

bailee 2004-08-03 12:05:23
和很多朋友一样,我也想详细了解top命令的原理,因为这是熟习Linux内核的一个好的切入点。
本人已下到top命令的源代码。
正如有的朋友所说的一样,不知道其结构看起来很乱,也无从下手。
所以请读过源码或知道其原理的高手指点一二,主要是top命令是怎样获取到相关数据的,在哪些源文件中有这些代码?Top命令的整体结构(有个框架图就行)又是怎样的?当然,与这些相关的源文件也可讲解一下。
有相关资料也行。
本人邮箱:bailee@126.com
所有资料可发到我的邮箱,同时也请在邮件中说明想在哪个版中要分,要多少(想要多少就直说哟 ^_^)等。交个朋友也行。
想要top命令源代码的朋友请到:
http://procps.sourceforge.net/download.html 下载。

本帖先给100分,是留给支持的朋友的哟!
感谢分在其它帖中分帖赠送!
...全文
229 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
bailee 2004-08-05
  • 打赏
  • 举报
回复
读了两天源代码,也了解了top源代码的结构了,正如楼上的朋友所说的一样,top就是这样。

我提议给 gettext(冰雪之崖) 多加100分,请版主注意呀!

出差几天,回来结帖!
gettext 2004-08-05
  • 打赏
  • 举报
回复
top是读/proc/的,

This proc-based top works by reading the files in the proc filesystem, mounted on
/proc. If /proc is not mounted, top will not work.

%CPU shows the cputime/realtime percentage in the period of time between updates.
For the first update, a short delay is used, and top itself dominates the CPU
usage. After that, top will drop back, and a more reliable estimate of CPU usage
is available.

The SIZE and RSS fields don't count the page tables and the task_struct of a pro­
cess; this is at least 12K of memory that is always resident. SIZE is the virtual
size of the process (code+data+stack).

Keep in mind that a process must die for its time to be recorded on its parent by
cumulative mode. Perhaps more useful behavior would be to follow each process
upwards, adding time, but that would be more expensive, possibly prohibitively so.
In any case, that would make top's behavior incompatible with ps.
bailee 2004-08-04
  • 打赏
  • 举报
回复
看来也只能这样了
skyupsky 2004-08-04
  • 打赏
  • 举报
回复
研究明白了就写点东西让大家分享吧!
沙沙的吹 2004-08-03
  • 打赏
  • 举报
回复
估计是读取的/proc文件系统的数据
Linux程序本来就很乱,不好读
你可以用source insight来观察,再乱都能找得出来。
bailee 2004-08-03
  • 打赏
  • 举报
回复
to YaST(敛分了敛分了):
嘿,老兄,你是用SuSE的吧!
bailee 2004-08-03
  • 打赏
  • 举报
回复
to Smallest(常住了) :
OK
YaST 2004-08-03
  • 打赏
  • 举报
回复
关注一下
金来 2004-08-03
  • 打赏
  • 举报
回复
有的话也随便发一份给我,正在研究

xdhua_@hotmail.com
bailee 2004-08-03
  • 打赏
  • 举报
回复
to happen23(微笑刺客):

首先谢谢的的回帖!

top还可动态显示进程方面的内容.通过它可了解很多内核结构。也并不是说非得从它学起。
至于文件系统,同样也不是非得从命令学呀,反正我是这么想的。不过学习linux文件系统得熟习它的结构,这可以从VFS研究起,如果非要说从哪个命令学起的话,我想说的是mount。你可从中看到很多结构,还可了解文件系统注册表及它与文件系统结构的一些关系。
gaoxianfeng 2004-08-03
  • 打赏
  • 举报
回复
up
六个九十度 2004-08-03
  • 打赏
  • 举报
回复
top好像是一个动态显示系统内存和CPU使用率的工具,用它来学习内核?如果是真的可以话
到可以研究研究,

那麽楼主,用哪个命令学习文件系统呢?再来个下载地址吧

19,613

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧