线程 CPU 时间的定义是什么



我们如何为非本机线程定义"线程CPU时间"? 更具体地说,它是如何在 JVM 上定义的(其中 CPU 可能是从 JVM 中抽象出来的,因此定义可能与较低级别的进程略有不同)....

我正在从这个测量的JVM实现开始工作:http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/management/ThreadMXBean.html 似乎没有直接定义"线程CPU时间"是直接测量的内容。

线程CPU时间已经是一个非常通用的术语。基本上,它代表CPU在给定线程上花费的时间。

的定义没有任何不同,因为它在JVM上,唯一要考虑的重要部分是JVM是否真的允许你测量它。有些有,有些没有。

不一定要打破抽象。POSIX 确实指定了一种测量每个线程的 CPU 时间的方法。然后是Windows:)

搜索热点源,我看到:

Hotspot/src/share/vm/runtime/os.hpp

  // JVMTI & JVM monitoring and management support
  // The thread_cpu_time() and current_thread_cpu_time() are only
  // supported if is_thread_cpu_time_supported() returns true.
  // They are not supported on Solaris T1.

hotspot/src/os/linux/vm/os_linux.cpp中,我确实看到了pthread_getcpuclockid以及用于此目的clock_gettime

hotspot/src/os/windows/vm/os_windows.cpp中,我看到使用了GetThreadTime

最新更新