38 // less than, equal to, or greater than active workers. If greater than
39 // or equal to active_workers, nothing is done.
40 // worker_type - type of thread.
41 // initializing - true if this is called to get the initial number of
42 // GC workers.
43 // If initializing is true, do a vm exit if the workers cannot be created.
44 // The initializing = true case is for JVM start up and failing to
45 // create all the worker at start should considered a problem so exit.
46 // If initializing = false, there are already some number of worker
47 // threads and a failure would not be optimal but should not be fatal.
48 template <class WorkerType>
49 static uint add_workers (WorkerType* holder,
50 uint active_workers,
51 uint total_workers,
52 uint created_workers,
53 os::ThreadType worker_type,
54 bool initializing) {
55 uint start = created_workers;
56 uint end = MIN2(active_workers, total_workers);
57 for (uint worker_id = start; worker_id < end; worker_id += 1) {
58 WorkerThread* new_worker = holder->install_worker(worker_id);
59 assert(new_worker != NULL, "Failed to allocate GangWorker");
60 if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
61 if(initializing) {
62 vm_exit_out_of_memory(0, OOM_MALLOC_ERROR,
63 "Cannot create worker GC thread. Out of system resources.");
64 }
65 }
66 created_workers++;
67 os::start_thread(new_worker);
68 }
69
70 log_trace(gc, task)("AdaptiveSizePolicy::add_workers() : "
71 "active_workers: %u created_workers: %u",
72 active_workers, created_workers);
73
74 return created_workers;
75 }
76 };
77 #endif // SHARE_VM_GC_SHARED_WORKERMANAGER_HPP
|
38 // less than, equal to, or greater than active workers. If greater than
39 // or equal to active_workers, nothing is done.
40 // worker_type - type of thread.
41 // initializing - true if this is called to get the initial number of
42 // GC workers.
43 // If initializing is true, do a vm exit if the workers cannot be created.
44 // The initializing = true case is for JVM start up and failing to
45 // create all the worker at start should considered a problem so exit.
46 // If initializing = false, there are already some number of worker
47 // threads and a failure would not be optimal but should not be fatal.
48 template <class WorkerType>
49 static uint add_workers (WorkerType* holder,
50 uint active_workers,
51 uint total_workers,
52 uint created_workers,
53 os::ThreadType worker_type,
54 bool initializing) {
55 uint start = created_workers;
56 uint end = MIN2(active_workers, total_workers);
57 for (uint worker_id = start; worker_id < end; worker_id += 1) {
58 WorkerThread* new_worker = NULL;
59 if (initializing || !InjectGCWorkerCreationFailure) {
60 new_worker = holder->install_worker(worker_id);
61 }
62 if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
63 log_trace(gc, task)("WorkerManager::add_workers() : "
64 "creation failed due to failed allocation of native %s",
65 new_worker == NULL ? "memory" : "thread");
66 if (new_worker != NULL) {
67 delete new_worker;
68 }
69 if (initializing) {
70 vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create worker GC thread. Out of system resources.");
71 }
72 break;
73 }
74 created_workers++;
75 os::start_thread(new_worker);
76 }
77
78 log_trace(gc, task)("WorkerManager::add_workers() : "
79 "created_workers: %u", created_workers);
80
81 return created_workers;
82 }
83 };
84 #endif // SHARE_VM_GC_SHARED_WORKERMANAGER_HPP
|