src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp

changeset 6690
1772223a25a2
parent 5237
f2110083203d
child 6876
710a3c8b516e
child 6904
0982ec23da03
     1.1 --- a/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Thu May 22 09:12:29 2014 +0200
     1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp	Fri Apr 11 11:00:12 2014 +0200
     1.3 @@ -89,6 +89,10 @@
     1.4    while (!_should_terminate) {
     1.5      // wait until started is set.
     1.6      sleepBeforeNextCycle();
     1.7 +    if (_should_terminate) {
     1.8 +      break;
     1.9 +    }
    1.10 +
    1.11      {
    1.12        ResourceMark rm;
    1.13        HandleMark   hm;
    1.14 @@ -303,11 +307,21 @@
    1.15  }
    1.16  
    1.17  void ConcurrentMarkThread::stop() {
    1.18 -  // it is ok to take late safepoints here, if needed
    1.19 -  MutexLockerEx mu(Terminator_lock);
    1.20 -  _should_terminate = true;
    1.21 -  while (!_has_terminated) {
    1.22 -    Terminator_lock->wait();
    1.23 +  {
    1.24 +    MutexLockerEx ml(Terminator_lock);
    1.25 +    _should_terminate = true;
    1.26 +  }
    1.27 +
    1.28 +  {
    1.29 +    MutexLockerEx ml(CGC_lock, Mutex::_no_safepoint_check_flag);
    1.30 +    CGC_lock->notify_all();
    1.31 +  }
    1.32 +
    1.33 +  {
    1.34 +    MutexLockerEx ml(Terminator_lock);
    1.35 +    while (!_has_terminated) {
    1.36 +      Terminator_lock->wait();
    1.37 +    }
    1.38    }
    1.39  }
    1.40  
    1.41 @@ -327,11 +341,14 @@
    1.42    assert(!in_progress(), "should have been cleared");
    1.43  
    1.44    MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
    1.45 -  while (!started()) {
    1.46 +  while (!started() && !_should_terminate) {
    1.47      CGC_lock->wait(Mutex::_no_safepoint_check_flag);
    1.48    }
    1.49 -  set_in_progress();
    1.50 -  clear_started();
    1.51 +
    1.52 +  if (started()) {
    1.53 +    set_in_progress();
    1.54 +    clear_started();
    1.55 +  }
    1.56  }
    1.57  
    1.58  // Note: As is the case with CMS - this method, although exported

mercurial