Mercurial > hg > graal-compiler
annotate src/share/vm/runtime/task.cpp @ 1833:8b10f48633dc
6984287: Regularize how GC parallel workers are specified.
Summary: Associate number of GC workers with the workgang as opposed to the task.
Reviewed-by: johnc, ysr
author | jmasa |
---|---|
date | Mon, 20 Sep 2010 14:38:38 -0700 |
parents | c18cbe5936b8 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
356
diff
changeset
|
2 * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
356
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
356
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
356
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_task.cpp.incl" | |
27 | |
28 int PeriodicTask::_num_tasks = 0; | |
29 PeriodicTask* PeriodicTask::_tasks[PeriodicTask::max_tasks]; | |
30 #ifndef PRODUCT | |
31 elapsedTimer PeriodicTask::_timer; | |
32 int PeriodicTask::_intervalHistogram[PeriodicTask::max_interval]; | |
33 int PeriodicTask::_ticks; | |
34 | |
35 void PeriodicTask::print_intervals() { | |
36 if (ProfilerCheckIntervals) { | |
37 for (int i = 0; i < PeriodicTask::max_interval; i++) { | |
38 int n = _intervalHistogram[i]; | |
39 if (n > 0) tty->print_cr("%3d: %5d (%4.1f%%)", i, n, 100.0 * n / _ticks); | |
40 } | |
41 } | |
42 } | |
43 #endif | |
44 | |
45 void PeriodicTask::real_time_tick(size_t delay_time) { | |
46 #ifndef PRODUCT | |
47 if (ProfilerCheckIntervals) { | |
48 _ticks++; | |
49 _timer.stop(); | |
50 int ms = (int)(_timer.seconds() * 1000.0); | |
51 _timer.reset(); | |
52 _timer.start(); | |
53 if (ms >= PeriodicTask::max_interval) ms = PeriodicTask::max_interval - 1; | |
54 _intervalHistogram[ms]++; | |
55 } | |
56 #endif | |
57 int orig_num_tasks = _num_tasks; | |
58 for(int index = 0; index < _num_tasks; index++) { | |
59 _tasks[index]->execute_if_pending(delay_time); | |
60 if (_num_tasks < orig_num_tasks) { // task dis-enrolled itself | |
61 index--; // re-do current slot as it has changed | |
62 orig_num_tasks = _num_tasks; | |
63 } | |
64 } | |
65 } | |
66 | |
67 | |
68 PeriodicTask::PeriodicTask(size_t interval_time) : | |
69 _counter(0), _interval(interval_time) { | |
70 // Sanity check the interval time | |
71 assert(_interval >= PeriodicTask::min_interval && | |
72 _interval <= PeriodicTask::max_interval && | |
73 _interval % PeriodicTask::interval_gran == 0, | |
74 "improper PeriodicTask interval time"); | |
75 } | |
76 | |
77 PeriodicTask::~PeriodicTask() { | |
78 if (is_enrolled()) | |
79 disenroll(); | |
80 } | |
81 | |
82 bool PeriodicTask::is_enrolled() const { | |
83 for(int index = 0; index < _num_tasks; index++) | |
84 if (_tasks[index] == this) return true; | |
85 return false; | |
86 } | |
87 | |
88 void PeriodicTask::enroll() { | |
89 assert(WatcherThread::watcher_thread() == NULL, "dynamic enrollment of tasks not yet supported"); | |
90 | |
91 if (_num_tasks == PeriodicTask::max_tasks) | |
92 fatal("Overflow in PeriodicTask table"); | |
93 _tasks[_num_tasks++] = this; | |
94 } | |
95 | |
96 void PeriodicTask::disenroll() { | |
97 assert(WatcherThread::watcher_thread() == NULL || | |
98 Thread::current() == WatcherThread::watcher_thread(), | |
99 "dynamic disenrollment currently only handled from WatcherThread from within task() method"); | |
100 | |
101 int index; | |
102 for(index = 0; index < _num_tasks && _tasks[index] != this; index++); | |
103 if (index == _num_tasks) return; | |
104 _num_tasks--; | |
105 for (; index < _num_tasks; index++) { | |
106 _tasks[index] = _tasks[index+1]; | |
107 } | |
108 } |