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
25 #include "precompiled.hpp"
26 #include "gc/parallel/gcTaskManager.hpp"
27 #include "gc/parallel/gcTaskThread.hpp"
28 #include "gc/shared/gcId.hpp"
29 #include "gc/shared/workerManager.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 #include "runtime/os.hpp"
38
39 //
40 // GCTask
41 //
42
43 const char* GCTask::Kind::to_string(kind value) {
44 const char* result = "unknown GCTask kind";
45 switch (value) {
46 default:
47 result = "unknown GCTask kind";
48 break;
49 case unknown_task:
50 result = "unknown task";
420 {
421 // Set up worker threads.
422 // Distribute the workers among the available processors,
423 // unless we were told not to, or if the os doesn't want to.
424 _processor_assignment = NEW_C_HEAP_ARRAY(uint, workers(), mtGC);
425 if (!BindGCTaskThreadsToCPUs ||
426 !os::distribute_processes(workers(), _processor_assignment)) {
427 for (uint a = 0; a < workers(); a += 1) {
428 _processor_assignment[a] = sentinel_worker();
429 }
430 }
431
432 _thread = NEW_C_HEAP_ARRAY(GCTaskThread*, workers(), mtGC);
433 _active_workers = ParallelGCThreads;
434 if (UseDynamicNumberOfGCThreads && !FLAG_IS_CMDLINE(ParallelGCThreads)) {
435 _active_workers = 1U;
436 }
437
438 Log(gc, task, thread) log;
439 if (log.is_trace()) {
440 ResourceMark rm;
441 outputStream* out = log.trace_stream();
442 out->print("GCTaskManager::initialize: distribution:");
443 for (uint t = 0; t < workers(); t += 1) {
444 out->print(" %u", _processor_assignment[t]);
445 }
446 out->cr();
447 }
448 }
449 reset_busy_workers();
450 set_unblocked();
451 for (uint w = 0; w < workers(); w += 1) {
452 set_resource_flag(w, false);
453 }
454 reset_delivered_tasks();
455 reset_completed_tasks();
456 reset_barriers();
457 reset_emptied_queue();
458
459 add_workers(true);
460 }
461
462 GCTaskManager::~GCTaskManager() {
463 assert(busy_workers() == 0, "still have busy workers");
464 assert(queue()->is_empty(), "still have queued work");
465 NoopGCTask::destroy(_noop_task);
466 _noop_task = NULL;
|
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
25 #include "precompiled.hpp"
26 #include "gc/parallel/gcTaskManager.hpp"
27 #include "gc/parallel/gcTaskThread.hpp"
28 #include "gc/shared/gcId.hpp"
29 #include "gc/shared/workerManager.hpp"
30 #include "logging/log.hpp"
31 #include "logging/logStream.hpp"
32 #include "memory/allocation.hpp"
33 #include "memory/allocation.inline.hpp"
34 #include "memory/resourceArea.hpp"
35 #include "runtime/mutex.hpp"
36 #include "runtime/mutexLocker.hpp"
37 #include "runtime/orderAccess.inline.hpp"
38 #include "runtime/os.hpp"
39
40 //
41 // GCTask
42 //
43
44 const char* GCTask::Kind::to_string(kind value) {
45 const char* result = "unknown GCTask kind";
46 switch (value) {
47 default:
48 result = "unknown GCTask kind";
49 break;
50 case unknown_task:
51 result = "unknown task";
421 {
422 // Set up worker threads.
423 // Distribute the workers among the available processors,
424 // unless we were told not to, or if the os doesn't want to.
425 _processor_assignment = NEW_C_HEAP_ARRAY(uint, workers(), mtGC);
426 if (!BindGCTaskThreadsToCPUs ||
427 !os::distribute_processes(workers(), _processor_assignment)) {
428 for (uint a = 0; a < workers(); a += 1) {
429 _processor_assignment[a] = sentinel_worker();
430 }
431 }
432
433 _thread = NEW_C_HEAP_ARRAY(GCTaskThread*, workers(), mtGC);
434 _active_workers = ParallelGCThreads;
435 if (UseDynamicNumberOfGCThreads && !FLAG_IS_CMDLINE(ParallelGCThreads)) {
436 _active_workers = 1U;
437 }
438
439 Log(gc, task, thread) log;
440 if (log.is_trace()) {
441 LogStream ls(log.trace());
442 ls.print("GCTaskManager::initialize: distribution:");
443 for (uint t = 0; t < workers(); t += 1) {
444 ls.print(" %u", _processor_assignment[t]);
445 }
446 ls.cr();
447 }
448 }
449 reset_busy_workers();
450 set_unblocked();
451 for (uint w = 0; w < workers(); w += 1) {
452 set_resource_flag(w, false);
453 }
454 reset_delivered_tasks();
455 reset_completed_tasks();
456 reset_barriers();
457 reset_emptied_queue();
458
459 add_workers(true);
460 }
461
462 GCTaskManager::~GCTaskManager() {
463 assert(busy_workers() == 0, "still have busy workers");
464 assert(queue()->is_empty(), "still have queued work");
465 NoopGCTask::destroy(_noop_task);
466 _noop_task = NULL;
|