src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp

Print this page
rev 4482 : 8013934: Garbage collection event for CMS has wrong cause for System.gc()


 123     while (!is_init_completed() && !Universe::is_fully_initialized() &&
 124            !_should_terminate) {
 125       CGC_lock->wait(true, 200);
 126       loopX.tick();
 127     }
 128     // Wait until the surrogate locker thread that will do
 129     // pending list locking on our behalf has been created.
 130     // We cannot start the SLT thread ourselves since we need
 131     // to be a JavaThread to do so.
 132     CMSLoopCountWarn loopY("CMS::run", "waiting for SLT installation", 2);
 133     while (_slt == NULL && !_should_terminate) {
 134       CGC_lock->wait(true, 200);
 135       loopY.tick();
 136     }
 137     clear_CMS_flag(CMS_cms_wants_token);
 138   }
 139 
 140   while (!_should_terminate) {
 141     sleepBeforeNextCycle();
 142     if (_should_terminate) break;
 143     _collector->collect_in_background(false);  // !clear_all_soft_refs


 144   }
 145   assert(_should_terminate, "just checking");
 146   // Check that the state of any protocol for synchronization
 147   // between background (CMS) and foreground collector is "clean"
 148   // (i.e. will not potentially block the foreground collector,
 149   // requiring action by us).
 150   verify_ok_to_terminate();
 151   // Signal that it is terminated
 152   {
 153     MutexLockerEx mu(Terminator_lock,
 154                      Mutex::_no_safepoint_check_flag);
 155     assert(_cmst == this, "Weird!");
 156     _cmst = NULL;
 157     Terminator_lock->notify();
 158   }
 159 
 160   // Thread destructor usually does this..
 161   ThreadLocalStorage::set_thread(NULL);
 162 }
 163 




 123     while (!is_init_completed() && !Universe::is_fully_initialized() &&
 124            !_should_terminate) {
 125       CGC_lock->wait(true, 200);
 126       loopX.tick();
 127     }
 128     // Wait until the surrogate locker thread that will do
 129     // pending list locking on our behalf has been created.
 130     // We cannot start the SLT thread ourselves since we need
 131     // to be a JavaThread to do so.
 132     CMSLoopCountWarn loopY("CMS::run", "waiting for SLT installation", 2);
 133     while (_slt == NULL && !_should_terminate) {
 134       CGC_lock->wait(true, 200);
 135       loopY.tick();
 136     }
 137     clear_CMS_flag(CMS_cms_wants_token);
 138   }
 139 
 140   while (!_should_terminate) {
 141     sleepBeforeNextCycle();
 142     if (_should_terminate) break;
 143     GCCause::Cause cause = _collector->_full_gc_requested ?
 144       _collector->_full_gc_cause : GCCause::_cms_concurrent_mark;
 145     _collector->collect_in_background(false, cause);
 146   }
 147   assert(_should_terminate, "just checking");
 148   // Check that the state of any protocol for synchronization
 149   // between background (CMS) and foreground collector is "clean"
 150   // (i.e. will not potentially block the foreground collector,
 151   // requiring action by us).
 152   verify_ok_to_terminate();
 153   // Signal that it is terminated
 154   {
 155     MutexLockerEx mu(Terminator_lock,
 156                      Mutex::_no_safepoint_check_flag);
 157     assert(_cmst == this, "Weird!");
 158     _cmst = NULL;
 159     Terminator_lock->notify();
 160   }
 161 
 162   // Thread destructor usually does this..
 163   ThreadLocalStorage::set_thread(NULL);
 164 }
 165