用户CPU时间与系统CPU时间?


User CPU time vs System CPU time?

你能解释一下"用户CPU时间"和"系统CPU时间"吗? 我读了很多,但我听不清楚。


不同之处在于时间是花在用户空间还是内核空间上。 用户CPU时间是运行程序代码(或库中的代码)的处理器所花费的时间; 系统CPU时间是代表程序在操作系统内核中运行代码所花费的时间。


术语"用户CPU时间"起初可能有点误导。 需要明确的是,总时间(实际CPU时间)是CPU为程序执行某些操作所花费的时间量与CPU为代表程序执行内核系统调用所花费的时间量的组合。 当程序循环遍历数组时,它会累积用户CPU时间。 相反,当程序执行系统调用(如exec或fork)时,它会累积系统CPU时间。


User CPU Time: Amount of time the processor worked on the specific program.

System CPU Time: Amount of time the processor worked on operating system's functions connected to that specific program.


基于维基百科:

  • User time is the amount of time the CPU was busy executing code in user space.
  • System time is the amount of time the CPU was busy executing code in kernel space. If this value is reported for a thread or
    process, then it represents the amount of time the kernel was doing
    work on behalf of the executing context, for example, after a thread
    issued a system call.