< prev index next >
src/hotspot/os/bsd/os_bsd.cpp
Print this page
*** 928,938 ****
const uint64_t now = (tm * Bsd::_timebase_info.numer) / Bsd::_timebase_info.denom;
const uint64_t prev = Bsd::_max_abstime;
if (now <= prev) {
return prev; // same or retrograde time;
}
! const uint64_t obsv = Atomic::cmpxchg(now, &Bsd::_max_abstime, 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
--- 928,938 ----
const uint64_t now = (tm * Bsd::_timebase_info.numer) / Bsd::_timebase_info.denom;
const uint64_t prev = Bsd::_max_abstime;
if (now <= prev) {
return prev; // same or retrograde time;
}
! const uint64_t obsv = Atomic::cmpxchg(&Bsd::_max_abstime, 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
*** 1831,1841 ****
static int check_pending_signals() {
for (;;) {
for (int i = 0; i < NSIG + 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);
--- 1831,1841 ----
static int check_pending_signals() {
for (;;) {
for (int i = 0; i < NSIG + 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);
*** 1892,1902 ****
if (!UseOprofile) {
return;
}
char buf[PATH_MAX + 1];
! int num = Atomic::add(1, &cnt);
snprintf(buf, PATH_MAX + 1, "%s/hs-vm-%d-%d",
os::get_temp_directory(), os::current_process_id(), num);
unlink(buf);
--- 1892,1902 ----
if (!UseOprofile) {
return;
}
char buf[PATH_MAX + 1];
! int num = Atomic::add(&cnt, 1);
snprintf(buf, PATH_MAX + 1, "%s/hs-vm-%d-%d",
os::get_temp_directory(), os::current_process_id(), num);
unlink(buf);
*** 3235,3245 ****
for (uint i = 0; i < max_apic_ids; ++i) {
mapping[i] = -1;
}
! if (!Atomic::replace_if_null(mapping, &apic_to_processor_mapping)) {
FREE_C_HEAP_ARRAY(int, mapping);
mapping = Atomic::load_acquire(&apic_to_processor_mapping);
}
}
--- 3235,3245 ----
for (uint i = 0; i < max_apic_ids; ++i) {
mapping[i] = -1;
}
! if (!Atomic::replace_if_null(&apic_to_processor_mapping, mapping)) {
FREE_C_HEAP_ARRAY(int, mapping);
mapping = Atomic::load_acquire(&apic_to_processor_mapping);
}
}
*** 3261,3272 ****
uint apic_id = edx;
int processor_id = Atomic::load(&mapping[apic_id]);
while (processor_id < 0) {
! if (Atomic::cmpxchg(-2, &mapping[apic_id], -1)) {
! Atomic::store(Atomic::add(1, &next_processor_id) - 1, &mapping[apic_id]);
}
processor_id = Atomic::load(&mapping[apic_id]);
}
return (uint)processor_id;
--- 3261,3272 ----
uint apic_id = edx;
int processor_id = Atomic::load(&mapping[apic_id]);
while (processor_id < 0) {
! if (Atomic::cmpxchg(&mapping[apic_id], -1, -2)) {
! Atomic::store(&mapping[apic_id], Atomic::add(&next_processor_id, 1) - 1);
}
processor_id = Atomic::load(&mapping[apic_id]);
}
return (uint)processor_id;
< prev index next >