src/share/vm/utilities/workgroup.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8047290absolutely_final Sdiff src/share/vm/utilities

src/share/vm/utilities/workgroup.cpp

Print this page




  29 #include "runtime/os.hpp"
  30 #include "utilities/workgroup.hpp"
  31 
  32 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  33 
  34 // Definitions of WorkGang methods.
  35 
  36 AbstractWorkGang::AbstractWorkGang(const char* name,
  37                                    bool  are_GC_task_threads,
  38                                    bool  are_ConcurrentGC_threads) :
  39   _name(name),
  40   _are_GC_task_threads(are_GC_task_threads),
  41   _are_ConcurrentGC_threads(are_ConcurrentGC_threads) {
  42 
  43   assert(!(are_GC_task_threads && are_ConcurrentGC_threads),
  44          "They cannot both be STW GC and Concurrent threads" );
  45 
  46   // Other initialization.
  47   _monitor = new Monitor(/* priority */       Mutex::leaf,
  48                          /* name */           "WorkGroup monitor",
  49                          /* allow_vm_block */ are_GC_task_threads);

  50   assert(monitor() != NULL, "Failed to allocate monitor");
  51   _terminate = false;
  52   _task = NULL;
  53   _sequence_number = 0;
  54   _started_workers = 0;
  55   _finished_workers = 0;
  56 }
  57 
  58 WorkGang::WorkGang(const char* name,
  59                    uint        workers,
  60                    bool        are_GC_task_threads,
  61                    bool        are_ConcurrentGC_threads) :
  62   AbstractWorkGang(name, are_GC_task_threads, are_ConcurrentGC_threads) {
  63   _total_workers = workers;
  64 }
  65 
  66 GangWorker* WorkGang::allocate_worker(uint which) {
  67   GangWorker* new_worker = new GangWorker(this, which);
  68   return new_worker;
  69 }


 361 // Printing methods
 362 
 363 const char* AbstractWorkGang::name() const {
 364   return _name;
 365 }
 366 
 367 #ifndef PRODUCT
 368 
 369 const char* AbstractGangTask::name() const {
 370   return _name;
 371 }
 372 
 373 #endif /* PRODUCT */
 374 
 375 // FlexibleWorkGang
 376 
 377 
 378 // *** WorkGangBarrierSync
 379 
 380 WorkGangBarrierSync::WorkGangBarrierSync()
 381   : _monitor(Mutex::safepoint, "work gang barrier sync", true),

 382     _n_workers(0), _n_completed(0), _should_reset(false), _aborted(false) {
 383 }
 384 
 385 WorkGangBarrierSync::WorkGangBarrierSync(uint n_workers, const char* name)
 386   : _monitor(Mutex::safepoint, name, true),
 387     _n_workers(n_workers), _n_completed(0), _should_reset(false), _aborted(false) {
 388 }
 389 
 390 void WorkGangBarrierSync::set_n_workers(uint n_workers) {
 391   _n_workers    = n_workers;
 392   _n_completed  = 0;
 393   _should_reset = false;
 394   _aborted      = false;
 395 }
 396 
 397 bool WorkGangBarrierSync::enter() {
 398   MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag);
 399   if (should_reset()) {
 400     // The should_reset() was set and we are the first worker to enter
 401     // the sync barrier. We will zero the n_completed() count which
 402     // effectively resets the barrier.
 403     zero_completed();
 404     set_should_reset(false);
 405   }
 406   inc_completed();




  29 #include "runtime/os.hpp"
  30 #include "utilities/workgroup.hpp"
  31 
  32 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  33 
  34 // Definitions of WorkGang methods.
  35 
  36 AbstractWorkGang::AbstractWorkGang(const char* name,
  37                                    bool  are_GC_task_threads,
  38                                    bool  are_ConcurrentGC_threads) :
  39   _name(name),
  40   _are_GC_task_threads(are_GC_task_threads),
  41   _are_ConcurrentGC_threads(are_ConcurrentGC_threads) {
  42 
  43   assert(!(are_GC_task_threads && are_ConcurrentGC_threads),
  44          "They cannot both be STW GC and Concurrent threads" );
  45 
  46   // Other initialization.
  47   _monitor = new Monitor(/* priority */       Mutex::leaf,
  48                          /* name */           "WorkGroup monitor",
  49                          /* allow_vm_block */ are_GC_task_threads,
  50                                               Monitor::_safepoint_check_sometimes);
  51   assert(monitor() != NULL, "Failed to allocate monitor");
  52   _terminate = false;
  53   _task = NULL;
  54   _sequence_number = 0;
  55   _started_workers = 0;
  56   _finished_workers = 0;
  57 }
  58 
  59 WorkGang::WorkGang(const char* name,
  60                    uint        workers,
  61                    bool        are_GC_task_threads,
  62                    bool        are_ConcurrentGC_threads) :
  63   AbstractWorkGang(name, are_GC_task_threads, are_ConcurrentGC_threads) {
  64   _total_workers = workers;
  65 }
  66 
  67 GangWorker* WorkGang::allocate_worker(uint which) {
  68   GangWorker* new_worker = new GangWorker(this, which);
  69   return new_worker;
  70 }


 362 // Printing methods
 363 
 364 const char* AbstractWorkGang::name() const {
 365   return _name;
 366 }
 367 
 368 #ifndef PRODUCT
 369 
 370 const char* AbstractGangTask::name() const {
 371   return _name;
 372 }
 373 
 374 #endif /* PRODUCT */
 375 
 376 // FlexibleWorkGang
 377 
 378 
 379 // *** WorkGangBarrierSync
 380 
 381 WorkGangBarrierSync::WorkGangBarrierSync()
 382   : _monitor(Mutex::safepoint, "work gang barrier sync", true,
 383              Monitor::_safepoint_check_never),
 384     _n_workers(0), _n_completed(0), _should_reset(false), _aborted(false) {
 385 }
 386 
 387 WorkGangBarrierSync::WorkGangBarrierSync(uint n_workers, const char* name)
 388   : _monitor(Mutex::safepoint, name, true, Monitor::_safepoint_check_never),
 389     _n_workers(n_workers), _n_completed(0), _should_reset(false), _aborted(false) {
 390 }
 391 
 392 void WorkGangBarrierSync::set_n_workers(uint n_workers) {
 393   _n_workers    = n_workers;
 394   _n_completed  = 0;
 395   _should_reset = false;
 396   _aborted      = false;
 397 }
 398 
 399 bool WorkGangBarrierSync::enter() {
 400   MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag);
 401   if (should_reset()) {
 402     // The should_reset() was set and we are the first worker to enter
 403     // the sync barrier. We will zero the n_completed() count which
 404     // effectively resets the barrier.
 405     zero_completed();
 406     set_should_reset(false);
 407   }
 408   inc_completed();


src/share/vm/utilities/workgroup.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File