为什么“top”显示某些进程的运行时间比系统的正常运行时间长?

she*_*wen 5 process top cpuinfo

我的系统出现问题,phantomjs在完成工作后仍然运行。为了调试这个问题,两天前我重新启动了系统:

屏幕截图显示了两天的正常运行时间

今天跑步的时候top看到了这个:

“顶部”的屏幕截图显示“时间”列中 130+ 的 phantomjs 进程

如果我理解正确,这两个phantomjs过程已经存在大约 5 天了。所以他们以某种方式在重启后幸存下来?

Byt*_*der 11

来自man top,“3a. 字段说明”部分:

   29. TIME  --  CPU Time
       Total  CPU  time the task has used since it started.  When Cumulative 
       mode is On, each process is listed with the cpu time that it and its 
       dead children have used.  You toggle Cumulative mode with `S',  which  
       is  both  a  command-line option and an interactive command. 
       See the `S' interactive command for additional information regarding 
       this mode.

   30. TIME+  --  CPU Time, hundredths
       The same as TIME, but reflecting more granularity through hundredths 
       of a second.
Run Code Online (Sandbox Code Playgroud)

CPU 时间是指单个 CPU 内核忙于处理此任务或(如果开启累积模式)其任何子进程的时间。

这意味着 CPU 时间与挂墙时间完全没有关系,它当然可以短于进程在挂墙时间中运行的时间(如果它不是一直使用完整的 CPU 内核),但也可以是比实际进程运行时间长(如果您有一个多核 CPU 并且该进程使用其中一个以上)。


use*_*274 10

TIME+列不是以小时和分钟为单位的挂钟时间,而是以分钟和秒(百分之一秒)为单位消耗的 CPU 时间。您的屏幕截图显示了两个 phantomjs 进程,每个进程使用了​​两个多小时的 CPU 时间。

  • @Phillip-ZyanKLee-Stockmann:在多核系统上,多线程进程很容易使用超过 100% 的 CPU 时间。例如,四核系统上的 x264(视频编码器)通常会获得可用 400% 的 360% 到 380%,具体取决于其他负载。在启动时运行长期 CPU 密集型多线程程序的服务器上,看到这一点很正常。 (6认同)
  • 不。这意味着他们从启动以来使用任何 cpu 核心两个多小时。尽管这会很奇怪,但进程可能会使用比系统正常运行时间更多的 CPU 时间。但这真的会给 CPU 带来压力...... (3认同)