(10) (M) RFR: 8174231: Factor out and share PlatformEvent and Parker code for POSIX systems (original) (raw)

David Holmes david.holmes at oracle.com
Fri May 19 11:36:11 UTC 2017


Correction ...

On 19/05/2017 8:53 PM, David Holmes wrote:

On 19/05/2017 7:25 PM, Robbin Ehn wrote:

On 05/19/2017 11:07 AM, David Holmes wrote:

They have to be as there are three cases: 1. Relative wait using CLOCKMONOTONIC 2. Relative wait using gettimeofday() 3. Absolute wait using gettimeofday()

Please consider something like:

#ifdef SUPPORTSCLOCKMONOTONIC if (useclockmonotoniccondattr && !isAbsolute) { // Why aren't we using this when not isAbsolute is set? // I suggest removing that check from this if and use monotonic for that also. Absolute waits have to be based on wall-clock time and follow any adjustments made to wall clock time. In contrast relative waits should never be affected by wall-clock time adjustments hence the use of CLOCKMONOTONIC when available. In Java the relative timed-waits are: - Thread.sleep(ms) - Object.wait(ms)/wait(ms,ns) - LockSupport.parkNanos(ns) (and all the j.u.c blocking methods built on top of it) While the only absolute timed-wait we have is the LockSupport.parkUntil method(s). Hope that clarifies things. Yes thanks! But you can still re-factoring to something similar to what I suggested and two of the calculation should be the same just ns vs us, correct? There are three different forms of the calculation. The two relative time versions use a different time function and so a different time structure (timeval vs timespec) and a different calculation. Leaving the if statement with the "!isAbsolute" check, in my head calctime is something like: void calctime(...) { if (isAbsolute) { calcabstime(...); } else { #ifdef SUPPORTSCLOCKMONOTONIC calcreltimefromclockmonotonic(...); #else > calcreltimefromgettimeofday(...); #endif } }

It's more complicated than that because we may have build time SUPPORTS_CLOCK_MONOTONIC but we still need the runtime check as well.

to_abstime is the old linux unpackTime with the addition of the build time conditionals.

David

David -----

I do not see a problem with this, only better readability?

/Robbin

Thanks, David ----- struct timespec now; int status = clockgettime(CLOCKMONOTONIC, &now); assertstatus(status == 0, status, "clockgettime"); calctime(abstime, timeout, isAbsolute, now.tvsec, now.tvnsec, NANOUNITS); } else { #else { #endif struct timeval now; int status = gettimeofday(&now, NULL); assert(status == 0, "gettimeofday"); calctime(abstime, timeout, isAbsolute, now.tvsec, now.tvusec, MICROUNITS); } #endif Thanks for fixing this! /Robbin



More information about the hotspot-dev mailing list