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 *
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/shared/gcId.hpp"
27 #include "gc/shared/workgroup.hpp"
28 #include "memory/allocation.hpp"
29 #include "memory/allocation.inline.hpp"
30 #include "runtime/atomic.inline.hpp"
31 #include "runtime/os.hpp"
32 #include "runtime/semaphore.hpp"
33 #include "runtime/thread.inline.hpp"
34
35 // Definitions of WorkGang methods.
36
37 // The current implementation will exit if the allocation
38 // of any worker fails. Still, return a boolean so that
39 // a future implementation can possibly do a partial
40 // initialization of the workers and report such to the
41 // caller.
42 bool AbstractWorkGang::initialize_workers() {
43
44 if (TraceWorkGang) {
45 tty->print_cr("Constructing work gang %s with %d threads",
46 name(),
312 gang()->dispatcher()->worker_done_with_task();
313 }
314
315 void GangWorker::print_task_started(WorkData data) {
316 if (TraceWorkGang) {
317 tty->print_cr("Running work gang %s task %s worker %u", name(), data._task->name(), data._worker_id);
318 }
319 }
320
321 void GangWorker::print_task_done(WorkData data) {
322 if (TraceWorkGang) {
323 tty->print_cr("\nFinished work gang %s task %s worker %u", name(), data._task->name(), data._worker_id);
324 Thread* me = Thread::current();
325 tty->print_cr(" T: " PTR_FORMAT " VM_thread: %d", p2i(me), me->is_VM_thread());
326 }
327 }
328
329 void GangWorker::run_task(WorkData data) {
330 print_task_started(data);
331
332 GCIdMark gc_id_mark(data._task->gc_id());
333 data._task->work(data._worker_id);
334
335 print_task_done(data);
336 }
337
338 void GangWorker::loop() {
339 while (true) {
340 WorkData data = wait_for_task();
341
342 run_task(data);
343
344 signal_task_done();
345 }
346 }
347
348 // *** WorkGangBarrierSync
349
350 WorkGangBarrierSync::WorkGangBarrierSync()
351 : _monitor(Mutex::safepoint, "work gang barrier sync", true,
352 Monitor::_safepoint_check_never),
|
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 *
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/shared/workgroup.hpp"
27 #include "memory/allocation.hpp"
28 #include "memory/allocation.inline.hpp"
29 #include "runtime/atomic.inline.hpp"
30 #include "runtime/os.hpp"
31 #include "runtime/semaphore.hpp"
32 #include "runtime/thread.inline.hpp"
33
34 // Definitions of WorkGang methods.
35
36 // The current implementation will exit if the allocation
37 // of any worker fails. Still, return a boolean so that
38 // a future implementation can possibly do a partial
39 // initialization of the workers and report such to the
40 // caller.
41 bool AbstractWorkGang::initialize_workers() {
42
43 if (TraceWorkGang) {
44 tty->print_cr("Constructing work gang %s with %d threads",
45 name(),
311 gang()->dispatcher()->worker_done_with_task();
312 }
313
314 void GangWorker::print_task_started(WorkData data) {
315 if (TraceWorkGang) {
316 tty->print_cr("Running work gang %s task %s worker %u", name(), data._task->name(), data._worker_id);
317 }
318 }
319
320 void GangWorker::print_task_done(WorkData data) {
321 if (TraceWorkGang) {
322 tty->print_cr("\nFinished work gang %s task %s worker %u", name(), data._task->name(), data._worker_id);
323 Thread* me = Thread::current();
324 tty->print_cr(" T: " PTR_FORMAT " VM_thread: %d", p2i(me), me->is_VM_thread());
325 }
326 }
327
328 void GangWorker::run_task(WorkData data) {
329 print_task_started(data);
330
331 data._task->work(data._worker_id);
332
333 print_task_done(data);
334 }
335
336 void GangWorker::loop() {
337 while (true) {
338 WorkData data = wait_for_task();
339
340 run_task(data);
341
342 signal_task_done();
343 }
344 }
345
346 // *** WorkGangBarrierSync
347
348 WorkGangBarrierSync::WorkGangBarrierSync()
349 : _monitor(Mutex::safepoint, "work gang barrier sync", true,
350 Monitor::_safepoint_check_never),
|