7117303: VM uses non-monotonic time source and complains that it is non-monotonic

Replaces calls to os::javaTimeMillis(), which does not (and cannot) guarantee monotonicity, in GC code to an equivalent expression that uses os::javaTimeNanos(). os::javaTimeNanos is guaranteed monotonically non-decreasing if the underlying platform provides a monotonic time source. Changes in OS files are to make use of the newly defined constants in globalDefinitions.hpp.

Reviewed-by: dholmes, ysr
This commit is contained in:
John Cuthbertson 2011-12-19 10:02:05 -08:00
parent 2768349b41
commit 870bea622a
10 changed files with 57 additions and 57 deletions

View file

@ -150,7 +150,6 @@
// for timer info max values which include all bits
#define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF)
#define SEC_IN_NANOSECS 1000000000LL
#define LARGEPAGES_BIT (1 << 6)
////////////////////////////////////////////////////////////////////////////////
@ -3445,8 +3444,6 @@ size_t os::read(int fd, void *buf, unsigned int nBytes) {
// generates a SIGUSRx signal. Note that SIGUSR1 can interfere with
// SIGSEGV, see 4355769.
const int NANOSECS_PER_MILLISECS = 1000000;
int os::sleep(Thread* thread, jlong millis, bool interruptible) {
assert(thread == Thread::current(), "thread consistency check");
@ -3469,7 +3466,7 @@ int os::sleep(Thread* thread, jlong millis, bool interruptible) {
// not a guarantee() because JVM should not abort on kernel/glibc bugs
assert(!Bsd::supports_monotonic_clock(), "time moving backwards");
} else {
millis -= (newtime - prevtime) / NANOSECS_PER_MILLISECS;
millis -= (newtime - prevtime) / NANOSECS_PER_MILLISEC;
}
if(millis <= 0) {
@ -3508,7 +3505,7 @@ int os::sleep(Thread* thread, jlong millis, bool interruptible) {
// not a guarantee() because JVM should not abort on kernel/glibc bugs
assert(!Bsd::supports_monotonic_clock(), "time moving backwards");
} else {
millis -= (newtime - prevtime) / NANOSECS_PER_MILLISECS;
millis -= (newtime - prevtime) / NANOSECS_PER_MILLISEC;
}
if(millis <= 0) break ;
@ -4197,7 +4194,7 @@ jlong os::Bsd::fast_thread_cpu_time(clockid_t clockid) {
int rc = os::Bsd::clock_gettime(clockid, &tp);
assert(rc == 0, "clock_gettime is expected to return 0 code");
return (tp.tv_sec * SEC_IN_NANOSECS) + tp.tv_nsec;
return (tp.tv_sec * NANOSECS_PER_SEC) + tp.tv_nsec;
}
#endif
@ -5522,9 +5519,6 @@ void os::PlatformEvent::unpark() {
* is no need to track notifications.
*/
#define NANOSECS_PER_SEC 1000000000
#define NANOSECS_PER_MILLISEC 1000000
#define MAX_SECS 100000000
/*
* This code is common to bsd and solaris and will be moved to a