Skip to content

Commit

Permalink
Fix shutdown protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
earthling-amzn committed Nov 6, 2024
1 parent 2320759 commit 89047a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahUncommitThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ void ShenandoahUncommitThread::run_service() {
last_shrink_time = current;
}
}
MonitorLocker locker(&_lock, Mutex::_no_safepoint_check_flag);
locker.wait((int64_t )shrink_period);
{
MonitorLocker locker(&_lock, Mutex::_no_safepoint_check_flag);
if (!_stop_requested.is_set()) {
locker.wait((int64_t )shrink_period);
}
}
}
}

Expand Down Expand Up @@ -135,3 +139,9 @@ void ShenandoahUncommitThread::uncommit(double shrink_before, size_t shrink_unti
log_info(gc)("Uncommitted " SIZE_FORMAT " regions, in %.3fs", count, elapsed);
}
}

void ShenandoahUncommitThread::stop_service() {
MonitorLocker locker(&_lock, Mutex::_no_safepoint_check_flag);
_stop_requested.set();
locker.notify_all();
}
3 changes: 2 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahUncommitThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ShenandoahUncommitThread : public ConcurrentGCThread {
ShenandoahHeap* _heap;
ShenandoahSharedFlag _soft_max_changed;
ShenandoahSharedFlag _explicit_gc_requested;
ShenandoahSharedFlag _stop_requested;
Monitor _lock;

bool has_work(double shrink_before, size_t shrink_until) const;
Expand All @@ -50,7 +51,7 @@ class ShenandoahUncommitThread : public ConcurrentGCThread {
void notify_explicit_gc_requested();

protected:
void stop_service() override {};
void stop_service() override;
};


Expand Down

0 comments on commit 89047a7

Please sign in to comment.