linux中top和ps的内存区别,linux - top与ps间的区别

Linux系统提供ps-oTHREAD和top两个命令来查询CPU使用率。ps-oTHREAD关注进程整个生命周期的CPU占用,而top则显示特定时间窗口内的实时CPU利用率。在多线程环境下,top可能报告超过100%的CPU使用率。理解这两个命令的差异对于系统监控和性能分析至关重要。
摘要由CSDN通过智能技术生成

背景

在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时间与该单位时间的百分比值。

总结

ps -o THREAD 命令更偏向于整个进程生命中占用CPU时间的比率。

top 命令更偏向于某个时间点占用CPU时间的比率。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值