当前位置:  技术问答>linux和unix

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

    来源: 互联网  发布时间:2015-07-12

    本文导语:  和很多朋友一样,我也想详细了解top命令的原理,因为这是熟习Linux内核的一个好的切入点。 本人已下到top命令的源代码。 正如有的朋友所说的一样,不知道其结构看起来很乱,也无从下手。 所以请读过源码或知道...

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

本帖先给100分,是留给支持的朋友的哟!
感谢分在其它帖中分帖赠送!

|
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.

|
top好像是一个动态显示系统内存和CPU使用率的工具,用它来学习内核?如果是真的可以话
到可以研究研究,

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

|
有的话也随便发一份给我,正在研究

xdhua_@hotmail.com

|
估计是读取的/proc文件系统的数据
Linux程序本来就很乱,不好读
你可以用source insight来观察,再乱都能找得出来。

|
up

|
关注一下

|
研究明白了就写点东西让大家分享吧!

    
 
 

您可能感兴趣的文章:

 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3