JDK using gettimeofday and not clock_gettime?

Florian Weimer fweimer at redhat.com
Fri Jul 23 12:23:50 UTC 2021

* Rohit Mohta:

>   While developing an in-house tool on system time related manipulation, we
> learnt Java uses gettimeofday() on linux-x86_64 system call for fetching
> System.currentTimeMillis().

You should not see any system call at all.  The call should go to the
vDSO and handled in userspace.

In current glibc, the implementation of gettimeofday is based on
clock_gettime (with CLOCK_REALTIME).  Calling clock_gettime directly
would avoid converting from nanoseconds to milliseconds in two stages, I
guess, but that's the only difference.


More information about the jdk-dev mailing list