< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp

Print this page
rev 59691 : 8247310: Shenandoah: pacer should not affect interrupt status
Reviewed-by: XXX

*** 26,35 **** --- 26,36 ---- #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahPacer.hpp" #include "runtime/atomic.hpp" + #include "runtime/mutexLocker.hpp" /* * In normal concurrent cycle, we have to pace the application to let GC finish. * * Here, we do not know how large would be the collection set, and what are the
*** 237,247 **** if (claim_for_alloc(words, false)) { return; } // Threads that are attaching should not block at all: they are not ! // fully initialized yet. Calling sleep() on them would be awkward. // This is probably the path that allocates the thread oop itself. // Forcefully claim without waiting. if (JavaThread::current()->is_attaching_via_jni()) { claim_for_alloc(words, true); return; --- 238,248 ---- if (claim_for_alloc(words, false)) { return; } // Threads that are attaching should not block at all: they are not ! // fully initialized yet. Blocking them would be awkward. // This is probably the path that allocates the thread oop itself. // Forcefully claim without waiting. if (JavaThread::current()->is_attaching_via_jni()) { claim_for_alloc(words, true); return;
*** 262,272 **** if (total + cur > max) { cur = (max > total) ? (max - total) : 0; } cur = MAX2<size_t>(1, cur); ! JavaThread::current()->sleep(cur); double end = os::elapsedTime(); total = (size_t)((end - start) * 1000); if (total > max) { --- 263,273 ---- if (total + cur > max) { cur = (max > total) ? (max - total) : 0; } cur = MAX2<size_t>(1, cur); ! wait(cur); double end = os::elapsedTime(); total = (size_t)((end - start) * 1000); if (total > max) {
*** 287,296 **** --- 288,310 ---- break; } } } + void ShenandoahPacer::wait(long time_ms) { + // Perform timed wait. It works like like sleep(), except without modifying + // the thread interruptible status. MonitorLocker also checks for safepoints. + assert(time_ms > 0, "Should not call this with zero argument, as it would stall until notify"); + MonitorLocker locker(_wait_monitor); + _wait_monitor->wait(time_ms); + } + + void ShenandoahPacer::notify_waiters() { + MonitorLocker locker(_wait_monitor); + _wait_monitor->notify_all(); + } + void ShenandoahPacer::print_on(outputStream* out) const { out->print_cr("ALLOCATION PACING:"); out->cr(); out->print_cr("Max pacing delay is set for " UINTX_FORMAT " ms.", ShenandoahPacingMaxDelay);
< prev index next >