src/hotspot/os/solaris/os_solaris.cpp
changeset 59252 623722a6aeb9
parent 59251 4cbfa5077d68
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
  1022   const hrtime_t now = gethrtime();
  1022   const hrtime_t now = gethrtime();
  1023   const hrtime_t prev = max_hrtime;
  1023   const hrtime_t prev = max_hrtime;
  1024   if (now <= prev) {
  1024   if (now <= prev) {
  1025     return prev;   // same or retrograde time;
  1025     return prev;   // same or retrograde time;
  1026   }
  1026   }
  1027   const hrtime_t obsv = Atomic::cmpxchg(now, &max_hrtime, prev);
  1027   const hrtime_t obsv = Atomic::cmpxchg(&max_hrtime, prev, now);
  1028   assert(obsv >= prev, "invariant");   // Monotonicity
  1028   assert(obsv >= prev, "invariant");   // Monotonicity
  1029   // If the CAS succeeded then we're done and return "now".
  1029   // If the CAS succeeded then we're done and return "now".
  1030   // If the CAS failed and the observed value "obsv" is >= now then
  1030   // If the CAS failed and the observed value "obsv" is >= now then
  1031   // we should return "obsv".  If the CAS failed and now > obsv > prv then
  1031   // we should return "obsv".  If the CAS failed and now > obsv > prv then
  1032   // some other thread raced this thread and installed a new value, in which case
  1032   // some other thread raced this thread and installed a new value, in which case
  1982 static int check_pending_signals() {
  1982 static int check_pending_signals() {
  1983   int ret;
  1983   int ret;
  1984   while (true) {
  1984   while (true) {
  1985     for (int i = 0; i < Sigexit + 1; i++) {
  1985     for (int i = 0; i < Sigexit + 1; i++) {
  1986       jint n = pending_signals[i];
  1986       jint n = pending_signals[i];
  1987       if (n > 0 && n == Atomic::cmpxchg(n - 1, &pending_signals[i], n)) {
  1987       if (n > 0 && n == Atomic::cmpxchg(&pending_signals[i], n, n - 1)) {
  1988         return i;
  1988         return i;
  1989       }
  1989       }
  1990     }
  1990     }
  1991     JavaThread *thread = JavaThread::current();
  1991     JavaThread *thread = JavaThread::current();
  1992     ThreadBlockInVM tbivm(thread);
  1992     ThreadBlockInVM tbivm(thread);
  4708   assert(_nParked == 0, "invariant");
  4708   assert(_nParked == 0, "invariant");
  4709 
  4709 
  4710   int v;
  4710   int v;
  4711   for (;;) {
  4711   for (;;) {
  4712     v = _Event;
  4712     v = _Event;
  4713     if (Atomic::cmpxchg(v-1, &_Event, v) == v) break;
  4713     if (Atomic::cmpxchg(&_Event, v, v-1) == v) break;
  4714   }
  4714   }
  4715   guarantee(v >= 0, "invariant");
  4715   guarantee(v >= 0, "invariant");
  4716   if (v == 0) {
  4716   if (v == 0) {
  4717     // Do this the hard way by blocking ...
  4717     // Do this the hard way by blocking ...
  4718     // See http://monaco.sfbay/detail.jsf?cr=5094058.
  4718     // See http://monaco.sfbay/detail.jsf?cr=5094058.
  4746 
  4746 
  4747   guarantee(_nParked == 0, "invariant");
  4747   guarantee(_nParked == 0, "invariant");
  4748   int v;
  4748   int v;
  4749   for (;;) {
  4749   for (;;) {
  4750     v = _Event;
  4750     v = _Event;
  4751     if (Atomic::cmpxchg(v-1, &_Event, v) == v) break;
  4751     if (Atomic::cmpxchg(&_Event, v, v-1) == v) break;
  4752   }
  4752   }
  4753   guarantee(v >= 0, "invariant");
  4753   guarantee(v >= 0, "invariant");
  4754   if (v != 0) return OS_OK;
  4754   if (v != 0) return OS_OK;
  4755 
  4755 
  4756   int ret = OS_TIMEOUT;
  4756   int ret = OS_TIMEOUT;