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 #include "precompiled.hpp"
26 #include "gc/parallel/gcTaskManager.hpp"
27 #include "gc/parallel/gcTaskThread.hpp"
28 #include "gc/shared/adaptiveSizePolicy.hpp"
29 #include "gc/shared/gcId.hpp"
30 #include "logging/log.hpp"
31 #include "memory/allocation.hpp"
32 #include "memory/allocation.inline.hpp"
33 #include "runtime/mutex.hpp"
34 #include "runtime/mutexLocker.hpp"
35 #include "runtime/orderAccess.inline.hpp"
36
37 //
38 // GCTask
39 //
40
41 const char* GCTask::Kind::to_string(kind value) {
42 const char* result = "unknown GCTask kind";
43 switch (value) {
44 default:
45 result = "unknown GCTask kind";
46 break;
47 case unknown_task:
48 result = "unknown task";
49 break;
50 case ordinary_task:
51 result = "ordinary task";
52 break;
387 // The queue for the GCTaskManager must be a CHeapObj.
388 GCTaskQueue* unsynchronized_queue = GCTaskQueue::create_on_c_heap();
389 _queue = SynchronizedGCTaskQueue::create(unsynchronized_queue, lock());
390 _noop_task = NoopGCTask::create_on_c_heap();
391 _resource_flag = NEW_C_HEAP_ARRAY(bool, workers(), mtGC);
392 {
393 // Set up worker threads.
394 // Distribute the workers among the available processors,
395 // unless we were told not to, or if the os doesn't want to.
396 uint* processor_assignment = NEW_C_HEAP_ARRAY(uint, workers(), mtGC);
397 if (!BindGCTaskThreadsToCPUs ||
398 !os::distribute_processes(workers(), processor_assignment)) {
399 for (uint a = 0; a < workers(); a += 1) {
400 processor_assignment[a] = sentinel_worker();
401 }
402 }
403 _thread = NEW_C_HEAP_ARRAY(GCTaskThread*, workers(), mtGC);
404 for (uint t = 0; t < workers(); t += 1) {
405 set_thread(t, GCTaskThread::create(this, t, processor_assignment[t]));
406 }
407 if (TraceGCTaskThread) {
408 tty->print("GCTaskManager::initialize: distribution:");
409 for (uint t = 0; t < workers(); t += 1) {
410 tty->print(" %u", processor_assignment[t]);
411 }
412 tty->cr();
413 }
414 FREE_C_HEAP_ARRAY(uint, processor_assignment);
415 }
416 reset_busy_workers();
417 set_unblocked();
418 for (uint w = 0; w < workers(); w += 1) {
419 set_resource_flag(w, false);
420 }
421 reset_delivered_tasks();
422 reset_completed_tasks();
423 reset_barriers();
424 reset_emptied_queue();
425 for (uint s = 0; s < workers(); s += 1) {
426 thread(s)->start();
427 }
428 }
429
430 GCTaskManager::~GCTaskManager() {
431 assert(busy_workers() == 0, "still have busy workers");
432 assert(queue()->is_empty(), "still have queued work");
|
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 #include "precompiled.hpp"
26 #include "gc/parallel/gcTaskManager.hpp"
27 #include "gc/parallel/gcTaskThread.hpp"
28 #include "gc/shared/adaptiveSizePolicy.hpp"
29 #include "gc/shared/gcId.hpp"
30 #include "logging/log.hpp"
31 #include "memory/allocation.hpp"
32 #include "memory/allocation.inline.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "runtime/mutex.hpp"
35 #include "runtime/mutexLocker.hpp"
36 #include "runtime/orderAccess.inline.hpp"
37
38 //
39 // GCTask
40 //
41
42 const char* GCTask::Kind::to_string(kind value) {
43 const char* result = "unknown GCTask kind";
44 switch (value) {
45 default:
46 result = "unknown GCTask kind";
47 break;
48 case unknown_task:
49 result = "unknown task";
50 break;
51 case ordinary_task:
52 result = "ordinary task";
53 break;
388 // The queue for the GCTaskManager must be a CHeapObj.
389 GCTaskQueue* unsynchronized_queue = GCTaskQueue::create_on_c_heap();
390 _queue = SynchronizedGCTaskQueue::create(unsynchronized_queue, lock());
391 _noop_task = NoopGCTask::create_on_c_heap();
392 _resource_flag = NEW_C_HEAP_ARRAY(bool, workers(), mtGC);
393 {
394 // Set up worker threads.
395 // Distribute the workers among the available processors,
396 // unless we were told not to, or if the os doesn't want to.
397 uint* processor_assignment = NEW_C_HEAP_ARRAY(uint, workers(), mtGC);
398 if (!BindGCTaskThreadsToCPUs ||
399 !os::distribute_processes(workers(), processor_assignment)) {
400 for (uint a = 0; a < workers(); a += 1) {
401 processor_assignment[a] = sentinel_worker();
402 }
403 }
404 _thread = NEW_C_HEAP_ARRAY(GCTaskThread*, workers(), mtGC);
405 for (uint t = 0; t < workers(); t += 1) {
406 set_thread(t, GCTaskThread::create(this, t, processor_assignment[t]));
407 }
408 LogHandle(gc, task, thread) log;
409 if (log.is_trace()) {
410 ResourceMark rm;
411 outputStream* out = log.trace_stream();
412 out->print("GCTaskManager::initialize: distribution:");
413 for (uint t = 0; t < workers(); t += 1) {
414 out->print(" %u", processor_assignment[t]);
415 }
416 out->cr();
417 }
418 FREE_C_HEAP_ARRAY(uint, processor_assignment);
419 }
420 reset_busy_workers();
421 set_unblocked();
422 for (uint w = 0; w < workers(); w += 1) {
423 set_resource_flag(w, false);
424 }
425 reset_delivered_tasks();
426 reset_completed_tasks();
427 reset_barriers();
428 reset_emptied_queue();
429 for (uint s = 0; s < workers(); s += 1) {
430 thread(s)->start();
431 }
432 }
433
434 GCTaskManager::~GCTaskManager() {
435 assert(busy_workers() == 0, "still have busy workers");
436 assert(queue()->is_empty(), "still have queued work");
|