hotspot/src/share/vm/gc/shared/concurrentGCThread.cpp
changeset 37081 7656f5356a5d
parent 36082 e734f3a55bdf
child 37129 af29e306e50b
equal deleted inserted replaced
37080:6f33de00485c 37081:7656f5356a5d
    35 
    35 
    36 ConcurrentGCThread::ConcurrentGCThread() :
    36 ConcurrentGCThread::ConcurrentGCThread() :
    37   _should_terminate(false), _has_terminated(false) {
    37   _should_terminate(false), _has_terminated(false) {
    38 };
    38 };
    39 
    39 
    40 void ConcurrentGCThread::create_and_start() {
    40 void ConcurrentGCThread::create_and_start(ThreadPriority prio) {
    41   if (os::create_thread(this, os::cgc_thread)) {
    41   if (os::create_thread(this, os::cgc_thread)) {
    42     // XXX: need to set this to low priority
    42     // XXX: need to set this to low priority
    43     // unless "aggressive mode" set; priority
    43     // unless "aggressive mode" set; priority
    44     // should be just less than that of VMThread.
    44     // should be just less than that of VMThread.
    45     os::set_priority(this, NearMaxPriority);
    45     os::set_priority(this, prio);
    46     if (!_should_terminate && !DisableStartThread) {
    46     if (!_should_terminate && !DisableStartThread) {
    47       os::start_thread(this);
    47       os::start_thread(this);
    48     }
    48     }
    49   }
    49   }
    50 }
    50 }
    70   {
    70   {
    71     MutexLockerEx mu(Terminator_lock,
    71     MutexLockerEx mu(Terminator_lock,
    72                      Mutex::_no_safepoint_check_flag);
    72                      Mutex::_no_safepoint_check_flag);
    73     _has_terminated = true;
    73     _has_terminated = true;
    74     Terminator_lock->notify();
    74     Terminator_lock->notify();
       
    75   }
       
    76 }
       
    77 
       
    78 void ConcurrentGCThread::run() {
       
    79   initialize_in_thread();
       
    80   wait_for_universe_init();
       
    81 
       
    82   run_service();
       
    83 
       
    84   terminate();
       
    85 }
       
    86 
       
    87 void ConcurrentGCThread::stop() {
       
    88   // it is ok to take late safepoints here, if needed
       
    89   {
       
    90     MutexLockerEx mu(Terminator_lock);
       
    91     assert(!_has_terminated,   "stop should only be called once");
       
    92     assert(!_should_terminate, "stop should only be called once");
       
    93     _should_terminate = true;
       
    94   }
       
    95 
       
    96   stop_service();
       
    97 
       
    98   {
       
    99     MutexLockerEx mu(Terminator_lock);
       
   100     while (!_has_terminated) {
       
   101       Terminator_lock->wait();
       
   102     }
    75   }
   103   }
    76 }
   104 }
    77 
   105 
    78 static void _sltLoop(JavaThread* thread, TRAPS) {
   106 static void _sltLoop(JavaThread* thread, TRAPS) {
    79   SurrogateLockerThread* slt = (SurrogateLockerThread*)thread;
   107   SurrogateLockerThread* slt = (SurrogateLockerThread*)thread;