简体   繁体   中英

What is the Definition of Thread CPU Time?

How do we define "thread CPU Time" for a non-native thread? More specifically, how is it defined on the JVM (where CPU is abstracted, presumeably, from the JVM, so the definition may be slightly different than for a lower level process)....

I'm working from the JVM implementation of this measurement: http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/management/ThreadMXBean.html which seems not to directly define what "Thread CPU time" is a direct measurement of.

Thread CPU Time is already a pretty generic term. Basically it stands for the amount of time the CPU spent on the given Thread.

It isn't defined any differently because it is on the JVM, the only important part to consider is whether the JVM actually lets you measure it. Some do and some don't.

One doesn't necessarily have to break the abstraction. POSIX does specify a way to measure cpu time per thread. And then there's Windows :)

Searching through the hotspot source, I see:

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.

In hotspot/src/os/linux/vm/os_linux.cpp I do see pthread_getcpuclockid along with clock_gettime being used for this purpose

In hotspot/src/os/windows/vm/os_windows.cpp , I see GetThreadTimes is used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM