我正在阅读有关计算进程的CPU使用情况。pcpu是什么意思,为什么乘以1000?
seconds = utime/Hertz
total_time = utime + stime
IF include_dead_children
total_time = total_time + cutime + cstime
ENDIF
seconds = uptime - starttime/Hertz
pcpu = (total_time * 1000/Hertz)/seconds
print: "%CPU" pcpu/10 "." pcpu % 10
我不明白的是,由“秒”的算法是指时间花在电脑做多兴趣的过程等操作,以及前。因为正常运行时间是我们计算机运行的时间,启动时间意味着我们[感兴趣]进程开始的时间。
那么我们为什么要把total_time
除以seconds
[计算机花时间做其他事情]得到pcpu
?这没有意义。
变量的标准含义:
# Name Description
14 utime CPU time spent in user code, measured in jiffies
15 stime CPU time spent in kernel code, measured in jiffies
16 cutime CPU time spent in user code, including time from children
17 cstime CPU time spent in kernel code, including time from children
22 starttime Time when the process started, measured in jiffies
/proc/uptime :The uptime of the system (seconds), and the amount of time spent in idle process (seconds).
Hertz :Number of clock ticks per second
由于我们不知道“utime”,“hertz”,“stime”,“cutime”,“ctimes”,“uptime”,“starttime”等的定义,回答这个问题需要做出相当多的假设。如果你能详细说明你的变量是什么以及它们包含什么值(或者它们来自哪里,至少)...... – twalberg
这些是标准术语。但是,我会为你更新这个问题。 – complextea