When is it more appropriate to use gethrvtime() instead of gethrtime()

1.2k Views Asked by At

Manpage for gethrtime() mentions another flavor of this call, which is gethrvtime(), and explains that this is the virtual time of a LWP. I am trying to understand the use case that would require gethrvtime() and make gethrtime() inapplicable and vice versa.

Thank you!

1

There are 1 best solutions below

1
On BEST ANSWER

This page on High Resolution Timers seems to have a good description of gethvrtime:

gethrvtime() and Light Weight Processes virtual time

The gethrvtime() function is similar to gethrtime() except that it returns the current high resolution Light Weight Process virtual time. Light Weight Processes (LWPs) are in Solaris parlance the equivalent of threads (LWPs were first implemented in Solaris. Later, they were later adopted by Linux and other POSIX systems). The LWP virtual time is the total number of nanoseconds of execution time. This function requires that micro state accounting be enabled with the ptime utility. Without getting too technical, using microstate accounting enables reproducible precision of time measurements.


It sounds to me like gethrtime is elapsed, "wall clock" time, whereas gethvrtime is CPU time.