< prev index next >

src/hotspot/share/gc/shared/concurrentGCThread.cpp

Print this page




  32 #include "runtime/javaCalls.hpp"
  33 #include "runtime/os.hpp"
  34 
  35 ConcurrentGCThread::ConcurrentGCThread() :
  36   _should_terminate(false), _has_terminated(false) {
  37 };
  38 
  39 void ConcurrentGCThread::create_and_start(ThreadPriority prio) {
  40   if (os::create_thread(this, os::cgc_thread)) {
  41     // XXX: need to set this to low priority
  42     // unless "aggressive mode" set; priority
  43     // should be just less than that of VMThread.
  44     os::set_priority(this, prio);
  45     if (!_should_terminate) {
  46       os::start_thread(this);
  47     }
  48   }
  49 }
  50 
  51 void ConcurrentGCThread::initialize_in_thread() {
  52   this->initialize_named_thread();
  53   this->set_active_handles(JNIHandleBlock::allocate_block());
  54   // From this time Thread::current() should be working.
  55   assert(this == Thread::current(), "just checking");
  56 }
  57 
  58 void ConcurrentGCThread::wait_for_universe_init() {
  59   MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
  60   while (!is_init_completed() && !_should_terminate) {
  61     CGC_lock->wait(Mutex::_no_safepoint_check_flag, 1);
  62   }
  63 }
  64 
  65 void ConcurrentGCThread::terminate() {
  66   assert(_should_terminate, "Should only be called on terminate request.");
  67   // Signal that it is terminated
  68   {
  69     MutexLockerEx mu(Terminator_lock,
  70                      Mutex::_no_safepoint_check_flag);
  71     _has_terminated = true;
  72     Terminator_lock->notify();




  32 #include "runtime/javaCalls.hpp"
  33 #include "runtime/os.hpp"
  34 
  35 ConcurrentGCThread::ConcurrentGCThread() :
  36   _should_terminate(false), _has_terminated(false) {
  37 };
  38 
  39 void ConcurrentGCThread::create_and_start(ThreadPriority prio) {
  40   if (os::create_thread(this, os::cgc_thread)) {
  41     // XXX: need to set this to low priority
  42     // unless "aggressive mode" set; priority
  43     // should be just less than that of VMThread.
  44     os::set_priority(this, prio);
  45     if (!_should_terminate) {
  46       os::start_thread(this);
  47     }
  48   }
  49 }
  50 
  51 void ConcurrentGCThread::initialize_in_thread() {

  52   this->set_active_handles(JNIHandleBlock::allocate_block());
  53   // From this time Thread::current() should be working.
  54   assert(this == Thread::current(), "just checking");
  55 }
  56 
  57 void ConcurrentGCThread::wait_for_universe_init() {
  58   MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
  59   while (!is_init_completed() && !_should_terminate) {
  60     CGC_lock->wait(Mutex::_no_safepoint_check_flag, 1);
  61   }
  62 }
  63 
  64 void ConcurrentGCThread::terminate() {
  65   assert(_should_terminate, "Should only be called on terminate request.");
  66   // Signal that it is terminated
  67   {
  68     MutexLockerEx mu(Terminator_lock,
  69                      Mutex::_no_safepoint_check_flag);
  70     _has_terminated = true;
  71     Terminator_lock->notify();


< prev index next >