linux - top与ps间的区别

2020-01-15 09:26:56来源:博客园 阅读 ()

容器云强势上线!快速搭建集群,上万Linux镜像随意使用

linux - top与ps间的区别

#背景   在linux系统中提供了2个查询系统负荷值的命令,一个是 ps -o THREAD 一个是 top ,这两个命令都能够查询当前进程的CPU使用率情况,但是所代表的含义确实不一样的,ps -o THREAD 偏向与整个进程周期所占的CPU使用率,而 top 更偏向于某个固定时间窗口的CPU使用率也就是说更倾向于查询实时CPU使用率。

#具体

NOTES
       This ps works by reading the virtual files in /proc.  This ps does not need to be setuid kmem or have any privileges to run.  Do not give this ps any special permissions.

       This ps needs access to namelist data for proper WCHAN display.  For kernels prior to 2.6, the System.map file must be installed.

       CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process.  This is not ideal, and it does not conform to the
       standards that ps otherwise conforms to.  CPU usage is unlikely to add up to exactly 100%.

  从第三行 CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process 可知 CPU使用率表示为进程整个生命周期中 与 运行在CPU上所花费的时间 百分比

1. %CPU  --  CPU Usage
           The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.

           In a true SMP environment, if a process is multi-threaded and top is not operating in Threads mode, amounts greater than 100% may be reported.  You toggle Threads mode
           with the `H' interactive command.

  根据 **CPU Usage The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.**知道CPU使用率是在一个单位时间窗口下该进程占用CPU时间与该单位时间的百分比值。

#总结

  1. ps -o THREAD 命令更偏向于整个进程生命中占用CPU时间的比率
  2. top 命令更偏向于某个时间点占用CPU时间的比率

原文链接:https://www.cnblogs.com/cjunn/p/12196085.html
如有疑问请与原作者联系

标签:AV系统POSTtimLinuxname

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Linux下VIM编译器的使用以及shell编程基础

下一篇:vmware进程,虚拟机NAT模式配置固定ip,访问外网与ping通主机