< prev index next >

src/share/vm/gc/shared/workgroup.hpp

Print this page




  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 
  25 #ifndef SHARE_VM_GC_SHARED_WORKGROUP_HPP
  26 #define SHARE_VM_GC_SHARED_WORKGROUP_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "runtime/globals.hpp"
  30 #include "runtime/thread.hpp"
  31 #include "gc/shared/gcId.hpp"

  32 #include "utilities/debug.hpp"
  33 #include "utilities/globalDefinitions.hpp"
  34 
  35 // Task class hierarchy:
  36 //   AbstractGangTask
  37 //
  38 // Gang/Group class hierarchy:
  39 //   AbstractWorkGang
  40 //     WorkGang
  41 //     YieldingFlexibleWorkGang (defined in another file)
  42 //
  43 // Worker class hierarchy:
  44 //   AbstractGangWorker (subclass of WorkerThread)
  45 //     GangWorker
  46 //     YieldingFlexibleGangWorker   (defined in another file)
  47 
  48 // Forward declarations of classes defined here
  49 
  50 class AbstractGangWorker;
  51 class Semaphore;


 134   bool are_GC_task_threads()      const { return _are_GC_task_threads; }
 135   bool are_ConcurrentGC_threads() const { return _are_ConcurrentGC_threads; }
 136 
 137   uint total_workers() const { return _total_workers; }
 138 
 139   virtual uint active_workers() const {
 140     assert(_active_workers <= _total_workers,
 141            "_active_workers: %u > _total_workers: %u", _active_workers, _total_workers);
 142     assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
 143            "Unless dynamic should use total workers");
 144     return _active_workers;
 145   }
 146   void set_active_workers(uint v) {
 147     assert(v <= _total_workers,
 148            "Trying to set more workers active than there are");
 149     _active_workers = MIN2(v, _total_workers);
 150     assert(v != 0, "Trying to set active workers to 0");
 151     _active_workers = MAX2(1U, _active_workers);
 152     assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
 153            "Unless dynamic should use total workers");

 154   }
 155 
 156   // Return the Ith worker.
 157   AbstractGangWorker* worker(uint i) const;
 158 
 159   void threads_do(ThreadClosure* tc) const;
 160 
 161   // Debugging.
 162   const char* name() const { return _name; }
 163 
 164   // Printing
 165   void print_worker_threads_on(outputStream *st) const;
 166   void print_worker_threads() const {
 167     print_worker_threads_on(tty);
 168   }
 169 
 170  protected:
 171   virtual AbstractGangWorker* allocate_worker(uint which) = 0;
 172 };
 173 




  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 
  25 #ifndef SHARE_VM_GC_SHARED_WORKGROUP_HPP
  26 #define SHARE_VM_GC_SHARED_WORKGROUP_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "runtime/globals.hpp"
  30 #include "runtime/thread.hpp"
  31 #include "gc/shared/gcId.hpp"
  32 #include "logging/log.hpp"
  33 #include "utilities/debug.hpp"
  34 #include "utilities/globalDefinitions.hpp"
  35 
  36 // Task class hierarchy:
  37 //   AbstractGangTask
  38 //
  39 // Gang/Group class hierarchy:
  40 //   AbstractWorkGang
  41 //     WorkGang
  42 //     YieldingFlexibleWorkGang (defined in another file)
  43 //
  44 // Worker class hierarchy:
  45 //   AbstractGangWorker (subclass of WorkerThread)
  46 //     GangWorker
  47 //     YieldingFlexibleGangWorker   (defined in another file)
  48 
  49 // Forward declarations of classes defined here
  50 
  51 class AbstractGangWorker;
  52 class Semaphore;


 135   bool are_GC_task_threads()      const { return _are_GC_task_threads; }
 136   bool are_ConcurrentGC_threads() const { return _are_ConcurrentGC_threads; }
 137 
 138   uint total_workers() const { return _total_workers; }
 139 
 140   virtual uint active_workers() const {
 141     assert(_active_workers <= _total_workers,
 142            "_active_workers: %u > _total_workers: %u", _active_workers, _total_workers);
 143     assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
 144            "Unless dynamic should use total workers");
 145     return _active_workers;
 146   }
 147   void set_active_workers(uint v) {
 148     assert(v <= _total_workers,
 149            "Trying to set more workers active than there are");
 150     _active_workers = MIN2(v, _total_workers);
 151     assert(v != 0, "Trying to set active workers to 0");
 152     _active_workers = MAX2(1U, _active_workers);
 153     assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
 154            "Unless dynamic should use total workers");
 155     log_info(gc, task)("GC Workers: %d", _active_workers);
 156   }
 157 
 158   // Return the Ith worker.
 159   AbstractGangWorker* worker(uint i) const;
 160 
 161   void threads_do(ThreadClosure* tc) const;
 162 
 163   // Debugging.
 164   const char* name() const { return _name; }
 165 
 166   // Printing
 167   void print_worker_threads_on(outputStream *st) const;
 168   void print_worker_threads() const {
 169     print_worker_threads_on(tty);
 170   }
 171 
 172  protected:
 173   virtual AbstractGangWorker* allocate_worker(uint which) = 0;
 174 };
 175 


< prev index next >