src/os/bsd/vm/os_bsd.cpp

Print this page
rev 2870 : 7117303: VM uses non-monotonic time source and complains that it is non-monotonic
Summary: Replaces calls to os::javaTimeMillis(), which does not guarantee montonicity, in GC code to os::javaTimeNanos() with a suitable conversion factor. os::javaTimeNanos is guaranteed monotonic if the underlying platform provides a monotonic timesource. Changes in OS files are to make use of the newly defined constants in globalDefinitions.hpp.
Reviewed-by: dholmes

*** 148,158 **** #define MAX_PATH (2 * K) // 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) //////////////////////////////////////////////////////////////////////////////// // global variables julong os::Bsd::_physical_memory = 0; --- 148,157 ----
*** 3443,3454 **** // Solaris uses poll(), bsd uses park(). // Poll() is likely a better choice, assuming that Thread.interrupt() // 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"); ParkEvent * const slp = thread->_SleepEvent ; slp->reset() ; --- 3442,3451 ----
*** 3467,3477 **** if (newtime - prevtime < 0) { // time moving backwards, should only happen if no monotonic clock // 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; } if(millis <= 0) { return OS_OK; } --- 3464,3474 ---- if (newtime - prevtime < 0) { // time moving backwards, should only happen if no monotonic clock // 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_MILLISEC; } if(millis <= 0) { return OS_OK; }
*** 3506,3516 **** if (newtime - prevtime < 0) { // time moving backwards, should only happen if no monotonic clock // 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; } if(millis <= 0) break ; prevtime = newtime; --- 3503,3513 ---- if (newtime - prevtime < 0) { // time moving backwards, should only happen if no monotonic clock // 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_MILLISEC; } if(millis <= 0) break ; prevtime = newtime;
*** 4195,4205 **** jlong os::Bsd::fast_thread_cpu_time(clockid_t clockid) { struct timespec tp; 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; } #endif ///// // glibc on Bsd platform uses non-documented flag --- 4192,4202 ---- jlong os::Bsd::fast_thread_cpu_time(clockid_t clockid) { struct timespec tp; int rc = os::Bsd::clock_gettime(clockid, &tp); assert(rc == 0, "clock_gettime is expected to return 0 code"); ! return (tp.tv_sec * NANOSECS_PER_SEC) + tp.tv_nsec; } #endif ///// // glibc on Bsd platform uses non-documented flag
*** 5520,5532 **** * on the condvar. Contention seen when trying to park implies that someone * is unparking you, so don't wait. And spurious returns are fine, so there * 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 * common place in dolphin. * --- 5517,5526 ----