254 uint workers,
255 bool are_GC_task_threads,
256 bool are_ConcurrentGC_threads) :
257 AbstractWorkGang(name, workers, are_GC_task_threads, are_ConcurrentGC_threads),
258 _dispatcher(create_dispatcher())
259 { }
260
261 AbstractGangWorker* WorkGang::allocate_worker(uint worker_id) {
262 return new GangWorker(this, worker_id);
263 }
264
265 void WorkGang::run_task(AbstractGangTask* task) {
266 run_task(task, active_workers());
267 }
268
269 void WorkGang::run_task(AbstractGangTask* task, uint num_workers) {
270 guarantee(num_workers <= total_workers(),
271 "Trying to execute task %s with %u workers which is more than the amount of total workers %u.",
272 task->name(), num_workers, total_workers());
273 guarantee(num_workers > 0, "Trying to execute task %s with zero workers", task->name());
274 add_workers(num_workers, false);
275 _dispatcher->coordinator_execute_on_workers(task, num_workers);
276 }
277
278 AbstractGangWorker::AbstractGangWorker(AbstractWorkGang* gang, uint id) {
279 _gang = gang;
280 set_id(id);
281 set_name("%s#%d", gang->name(), id);
282 }
283
284 void AbstractGangWorker::run() {
285 initialize();
286 loop();
287 }
288
289 void AbstractGangWorker::initialize() {
290 this->record_stack_base_and_size();
291 this->initialize_named_thread();
292 assert(_gang != NULL, "No gang to run in");
293 os::set_priority(this, NearMaxPriority);
294 log_develop_trace(gc, workgang)("Running gang worker for gang %s id %u", gang()->name(), id());
295 // The VM thread should not execute here because MutexLocker's are used
|
254 uint workers,
255 bool are_GC_task_threads,
256 bool are_ConcurrentGC_threads) :
257 AbstractWorkGang(name, workers, are_GC_task_threads, are_ConcurrentGC_threads),
258 _dispatcher(create_dispatcher())
259 { }
260
261 AbstractGangWorker* WorkGang::allocate_worker(uint worker_id) {
262 return new GangWorker(this, worker_id);
263 }
264
265 void WorkGang::run_task(AbstractGangTask* task) {
266 run_task(task, active_workers());
267 }
268
269 void WorkGang::run_task(AbstractGangTask* task, uint num_workers) {
270 guarantee(num_workers <= total_workers(),
271 "Trying to execute task %s with %u workers which is more than the amount of total workers %u.",
272 task->name(), num_workers, total_workers());
273 guarantee(num_workers > 0, "Trying to execute task %s with zero workers", task->name());
274 uint old_num_workers = _active_workers;
275 log_debug(gc)("run_task: updating active workers for %s from %u to %u", task->name(), old_num_workers, num_workers);
276 update_active_workers(num_workers);
277 guarantee(_active_workers == num_workers, "active workers %u num_workers %u", _active_workers, num_workers);
278 _dispatcher->coordinator_execute_on_workers(task, num_workers);
279 log_debug(gc)("run_task: restoring active workers from %u to %u", num_workers, old_num_workers);
280 update_active_workers(old_num_workers);
281 }
282
283 AbstractGangWorker::AbstractGangWorker(AbstractWorkGang* gang, uint id) {
284 _gang = gang;
285 set_id(id);
286 set_name("%s#%d", gang->name(), id);
287 }
288
289 void AbstractGangWorker::run() {
290 initialize();
291 loop();
292 }
293
294 void AbstractGangWorker::initialize() {
295 this->record_stack_base_and_size();
296 this->initialize_named_thread();
297 assert(_gang != NULL, "No gang to run in");
298 os::set_priority(this, NearMaxPriority);
299 log_develop_trace(gc, workgang)("Running gang worker for gang %s id %u", gang()->name(), id());
300 // The VM thread should not execute here because MutexLocker's are used
|