JDK using gettimeofday and not clock_gettime?
Rohit Mohta
rmohta.coder at gmail.com
Fri Jul 23 12:16:47 UTC 2021
Hello,
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().
I was wondering if we thought of using clock_gettime() system call on
Linux? Or if there are plans to update them to align with the POSIX
recommendation. From what I can see Golang, Rust are using clock_gettime().
https://github.com/openjdk/jdk11u/blob/master/src/hotspot/os/linux/os_linux.cpp#L1295-L1300
int status = gettimeofday(&time, NULL);
Per https://man7.org/linux/man-pages/man2/settimeofday.2.html
POSIX.1-2008 marks *gettimeofday*() as obsolete,
> recommending the use of clock_gettime(2)
> <https://man7.org/linux/man-pages/man2/clock_gettime.2.html> instead
Thanks!
More information about the jdk-dev
mailing list