< prev index next >
src/hotspot/os/solaris/os_solaris.cpp
Print this page
*** 1022,1032 ****
const hrtime_t now = gethrtime();
const hrtime_t prev = max_hrtime;
if (now <= prev) {
return prev; // same or retrograde time;
}
! const hrtime_t obsv = Atomic::cmpxchg(now, &max_hrtime, prev);
assert(obsv >= prev, "invariant"); // Monotonicity
// If the CAS succeeded then we're done and return "now".
// If the CAS failed and the observed value "obsv" is >= now then
// we should return "obsv". If the CAS failed and now > obsv > prv then
// some other thread raced this thread and installed a new value, in which case
--- 1022,1032 ----
const hrtime_t now = gethrtime();
const hrtime_t prev = max_hrtime;
if (now <= prev) {
return prev; // same or retrograde time;
}
! const hrtime_t obsv = Atomic::cmpxchg(&max_hrtime, prev, now);
assert(obsv >= prev, "invariant"); // Monotonicity
// If the CAS succeeded then we're done and return "now".
// If the CAS failed and the observed value "obsv" is >= now then
// we should return "obsv". If the CAS failed and now > obsv > prv then
// some other thread raced this thread and installed a new value, in which case
*** 1982,1992 ****
static int check_pending_signals() {
int ret;
while (true) {
for (int i = 0; i < Sigexit + 1; i++) {
jint n = pending_signals[i];
! if (n > 0 && n == Atomic::cmpxchg(n - 1, &pending_signals[i], n)) {
return i;
}
}
JavaThread *thread = JavaThread::current();
ThreadBlockInVM tbivm(thread);
--- 1982,1992 ----
static int check_pending_signals() {
int ret;
while (true) {
for (int i = 0; i < Sigexit + 1; i++) {
jint n = pending_signals[i];
! if (n > 0 && n == Atomic::cmpxchg(&pending_signals[i], n, n - 1)) {
return i;
}
}
JavaThread *thread = JavaThread::current();
ThreadBlockInVM tbivm(thread);
*** 4708,4718 ****
assert(_nParked == 0, "invariant");
int v;
for (;;) {
v = _Event;
! if (Atomic::cmpxchg(v-1, &_Event, v) == v) break;
}
guarantee(v >= 0, "invariant");
if (v == 0) {
// Do this the hard way by blocking ...
// See http://monaco.sfbay/detail.jsf?cr=5094058.
--- 4708,4718 ----
assert(_nParked == 0, "invariant");
int v;
for (;;) {
v = _Event;
! if (Atomic::cmpxchg(&_Event, v, v-1) == v) break;
}
guarantee(v >= 0, "invariant");
if (v == 0) {
// Do this the hard way by blocking ...
// See http://monaco.sfbay/detail.jsf?cr=5094058.
*** 4746,4756 ****
guarantee(_nParked == 0, "invariant");
int v;
for (;;) {
v = _Event;
! if (Atomic::cmpxchg(v-1, &_Event, v) == v) break;
}
guarantee(v >= 0, "invariant");
if (v != 0) return OS_OK;
int ret = OS_TIMEOUT;
--- 4746,4756 ----
guarantee(_nParked == 0, "invariant");
int v;
for (;;) {
v = _Event;
! if (Atomic::cmpxchg(&_Event, v, v-1) == v) break;
}
guarantee(v >= 0, "invariant");
if (v != 0) return OS_OK;
int ret = OS_TIMEOUT;
*** 4795,4805 ****
// that it will take two back-to-back park() calls for the owning
// thread to block. This has the benefit of forcing a spurious return
// from the first park() call after an unpark() call which will help
// shake out uses of park() and unpark() without condition variables.
! if (Atomic::xchg(1, &_Event) >= 0) return;
// If the thread associated with the event was parked, wake it.
// Wait for the thread assoc with the PlatformEvent to vacate.
int status = os::Solaris::mutex_lock(_mutex);
assert_status(status == 0, status, "mutex_lock");
--- 4795,4805 ----
// that it will take two back-to-back park() calls for the owning
// thread to block. This has the benefit of forcing a spurious return
// from the first park() call after an unpark() call which will help
// shake out uses of park() and unpark() without condition variables.
! if (Atomic::xchg(&_Event, 1) >= 0) return;
// If the thread associated with the event was parked, wake it.
// Wait for the thread assoc with the PlatformEvent to vacate.
int status = os::Solaris::mutex_lock(_mutex);
assert_status(status == 0, status, "mutex_lock");
*** 4894,4904 ****
// Optional fast-path check:
// Return immediately if a permit is available.
// We depend on Atomic::xchg() having full barrier semantics
// since we are doing a lock-free update to _counter.
! if (Atomic::xchg(0, &_counter) > 0) return;
// Optional fast-exit: Check interrupt before trying to wait
Thread* thread = Thread::current();
assert(thread->is_Java_thread(), "Must be JavaThread");
JavaThread *jt = (JavaThread *)thread;
--- 4894,4904 ----
// Optional fast-path check:
// Return immediately if a permit is available.
// We depend on Atomic::xchg() having full barrier semantics
// since we are doing a lock-free update to _counter.
! if (Atomic::xchg(&_counter, 0) > 0) return;
// Optional fast-exit: Check interrupt before trying to wait
Thread* thread = Thread::current();
assert(thread->is_Java_thread(), "Must be JavaThread");
JavaThread *jt = (JavaThread *)thread;
< prev index next >