< prev index next >

src/hotspot/share/gc/z/zWorkers.cpp

Print this page




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"

  25 #include "gc/z/zGlobals.hpp"
  26 #include "gc/z/zTask.hpp"
  27 #include "gc/z/zThread.hpp"
  28 #include "gc/z/zWorkers.inline.hpp"
  29 #include "runtime/mutexLocker.hpp"
  30 #include "runtime/safepoint.hpp"
  31 
  32 class ZWorkersInitializeTask : public ZTask {
  33 private:
  34   const uint _nworkers;
  35   uint       _started;
  36   Monitor    _monitor;
  37 
  38 public:
  39   ZWorkersInitializeTask(uint nworkers) :
  40       ZTask("ZWorkersInitializeTask"),
  41       _nworkers(nworkers),
  42       _started(0),
  43       _monitor(Monitor::leaf,
  44                "ZWorkersInitialize",


  52     // Wait for all threads to start
  53     MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag);
  54     if (++_started == _nworkers) {
  55       // All threads started
  56       ml.notify_all();
  57     } else {
  58       while (_started != _nworkers) {
  59         ml.wait();
  60       }
  61     }
  62   }
  63 };
  64 
  65 ZWorkers::ZWorkers() :
  66     _boost(false),
  67     _workers("ZWorker",
  68              nworkers(),
  69              true /* are_GC_task_threads */,
  70              true /* are_ConcurrentGC_threads */) {
  71 
  72   log_info(gc, init)("Workers: %u parallel, %u concurrent", nparallel(), nconcurrent());
  73 
  74   // Initialize worker threads
  75   _workers.initialize_workers();
  76   _workers.update_active_workers(nworkers());
  77   if (_workers.active_workers() != nworkers()) {
  78     vm_exit_during_initialization("Failed to create ZWorkers");
  79   }
  80 
  81   // Execute task to register threads as workers. This also helps
  82   // reduce latency in early GC pauses, which otherwise would have
  83   // to take on any warmup costs.
  84   ZWorkersInitializeTask task(nworkers());
  85   run(&task, nworkers());
  86 }
  87 
  88 void ZWorkers::set_boost(bool boost) {
  89   if (boost) {
  90     log_debug(gc)("Boosting workers");
  91   }
  92 




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 #include "precompiled.hpp"
  25 #include "gc/shared/gcLogPrecious.hpp"
  26 #include "gc/z/zGlobals.hpp"
  27 #include "gc/z/zTask.hpp"
  28 #include "gc/z/zThread.hpp"
  29 #include "gc/z/zWorkers.inline.hpp"
  30 #include "runtime/mutexLocker.hpp"
  31 #include "runtime/safepoint.hpp"
  32 
  33 class ZWorkersInitializeTask : public ZTask {
  34 private:
  35   const uint _nworkers;
  36   uint       _started;
  37   Monitor    _monitor;
  38 
  39 public:
  40   ZWorkersInitializeTask(uint nworkers) :
  41       ZTask("ZWorkersInitializeTask"),
  42       _nworkers(nworkers),
  43       _started(0),
  44       _monitor(Monitor::leaf,
  45                "ZWorkersInitialize",


  53     // Wait for all threads to start
  54     MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag);
  55     if (++_started == _nworkers) {
  56       // All threads started
  57       ml.notify_all();
  58     } else {
  59       while (_started != _nworkers) {
  60         ml.wait();
  61       }
  62     }
  63   }
  64 };
  65 
  66 ZWorkers::ZWorkers() :
  67     _boost(false),
  68     _workers("ZWorker",
  69              nworkers(),
  70              true /* are_GC_task_threads */,
  71              true /* are_ConcurrentGC_threads */) {
  72 
  73   log_info_p(gc, init)("Workers: %u parallel, %u concurrent", nparallel(), nconcurrent());
  74 
  75   // Initialize worker threads
  76   _workers.initialize_workers();
  77   _workers.update_active_workers(nworkers());
  78   if (_workers.active_workers() != nworkers()) {
  79     vm_exit_during_initialization("Failed to create ZWorkers");
  80   }
  81 
  82   // Execute task to register threads as workers. This also helps
  83   // reduce latency in early GC pauses, which otherwise would have
  84   // to take on any warmup costs.
  85   ZWorkersInitializeTask task(nworkers());
  86   run(&task, nworkers());
  87 }
  88 
  89 void ZWorkers::set_boost(bool boost) {
  90   if (boost) {
  91     log_debug(gc)("Boosting workers");
  92   }
  93 


< prev index next >