src/share/vm/runtime/os.cpp

changeset 496
5a76ab815e34
parent 490
2a8eb116ebbe
child 631
d1605aabd0a1
     1.1 --- a/src/share/vm/runtime/os.cpp	Fri Mar 14 10:43:02 2008 -0400
     1.2 +++ b/src/share/vm/runtime/os.cpp	Wed Mar 19 09:58:01 2008 -0400
     1.3 @@ -33,9 +33,6 @@
     1.4  uintptr_t         os::_serialize_page_mask = 0;
     1.5  long              os::_rand_seed          = 1;
     1.6  int               os::_processor_count    = 0;
     1.7 -volatile jlong    os::_global_time        = 0;
     1.8 -volatile int      os::_global_time_lock   = 0;
     1.9 -bool              os::_use_global_time    = false;
    1.10  size_t            os::_page_sizes[os::page_sizes_max];
    1.11  
    1.12  #ifndef PRODUCT
    1.13 @@ -44,74 +41,6 @@
    1.14  int os::num_frees = 0;              // # of calls to free
    1.15  #endif
    1.16  
    1.17 -// Atomic read of a jlong is assured by a seqlock; see update_global_time()
    1.18 -jlong os::read_global_time() {
    1.19 -#ifdef _LP64
    1.20 -  return _global_time;
    1.21 -#else
    1.22 -  volatile int lock;
    1.23 -  volatile jlong current_time;
    1.24 -  int ctr = 0;
    1.25 -
    1.26 -  for (;;) {
    1.27 -    lock = _global_time_lock;
    1.28 -
    1.29 -    // spin while locked
    1.30 -    while ((lock & 0x1) != 0) {
    1.31 -      ++ctr;
    1.32 -      if ((ctr & 0xFFF) == 0) {
    1.33 -        // Guarantee writer progress.  Can't use yield; yield is advisory
    1.34 -        // and has almost no effect on some platforms.  Don't need a state
    1.35 -        // transition - the park call will return promptly.
    1.36 -        assert(Thread::current() != NULL, "TLS not initialized");
    1.37 -        assert(Thread::current()->_ParkEvent != NULL, "sync not initialized");
    1.38 -        Thread::current()->_ParkEvent->park(1);
    1.39 -      }
    1.40 -      lock = _global_time_lock;
    1.41 -    }
    1.42 -
    1.43 -    OrderAccess::loadload();
    1.44 -    current_time = _global_time;
    1.45 -    OrderAccess::loadload();
    1.46 -
    1.47 -    // ratify seqlock value
    1.48 -    if (lock == _global_time_lock) {
    1.49 -      return current_time;
    1.50 -    }
    1.51 -  }
    1.52 -#endif
    1.53 -}
    1.54 -
    1.55 -//
    1.56 -// NOTE - Assumes only one writer thread!
    1.57 -//
    1.58 -// We use a seqlock to guarantee that jlong _global_time is updated
    1.59 -// atomically on 32-bit platforms.  A locked value is indicated by
    1.60 -// the lock variable LSB == 1.  Readers will initially read the lock
    1.61 -// value, spinning until the LSB == 0.  They then speculatively read
    1.62 -// the global time value, then re-read the lock value to ensure that
    1.63 -// it hasn't changed.  If the lock value has changed, the entire read
    1.64 -// sequence is retried.
    1.65 -//
    1.66 -// Writers simply set the LSB = 1 (i.e. increment the variable),
    1.67 -// update the global time, then release the lock and bump the version
    1.68 -// number (i.e. increment the variable again.)  In this case we don't
    1.69 -// even need a CAS since we ensure there's only one writer.
    1.70 -//
    1.71 -void os::update_global_time() {
    1.72 -#ifdef _LP64
    1.73 -  _global_time = timeofday();
    1.74 -#else
    1.75 -  assert((_global_time_lock & 0x1) == 0, "multiple writers?");
    1.76 -  jlong current_time = timeofday();
    1.77 -  _global_time_lock++; // lock
    1.78 -  OrderAccess::storestore();
    1.79 -  _global_time = current_time;
    1.80 -  OrderAccess::storestore();
    1.81 -  _global_time_lock++; // unlock
    1.82 -#endif
    1.83 -}
    1.84 -
    1.85  // Fill in buffer with current local time as an ISO-8601 string.
    1.86  // E.g., yyyy-mm-ddThh:mm:ss-zzzz.
    1.87  // Returns buffer, or NULL if it failed.
    1.88 @@ -138,7 +67,7 @@
    1.89      return NULL;
    1.90    }
    1.91    // Get the current time
    1.92 -  jlong milliseconds_since_19700101 = timeofday();
    1.93 +  jlong milliseconds_since_19700101 = javaTimeMillis();
    1.94    const int milliseconds_per_microsecond = 1000;
    1.95    const time_t seconds_since_19700101 =
    1.96      milliseconds_since_19700101 / milliseconds_per_microsecond;

mercurial