ysr@777: /* johnc@3463: * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. ysr@777: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ysr@777: * ysr@777: * This code is free software; you can redistribute it and/or modify it ysr@777: * under the terms of the GNU General Public License version 2 only, as ysr@777: * published by the Free Software Foundation. ysr@777: * ysr@777: * This code is distributed in the hope that it will be useful, but WITHOUT ysr@777: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ysr@777: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ysr@777: * version 2 for more details (a copy is included in the LICENSE file that ysr@777: * accompanied this code). ysr@777: * ysr@777: * You should have received a copy of the GNU General Public License version ysr@777: * 2 along with this work; if not, write to the Free Software Foundation, ysr@777: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ysr@777: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. ysr@777: * ysr@777: */ ysr@777: stefank@2314: #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARKTHREAD_HPP stefank@2314: #define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARKTHREAD_HPP stefank@2314: stefank@2314: #include "gc_implementation/shared/concurrentGCThread.hpp" stefank@2314: ysr@777: // The Concurrent Mark GC Thread (could be several in the future). ysr@777: // This is copied from the Concurrent Mark Sweep GC Thread ysr@777: // Still under construction. ysr@777: ysr@777: class ConcurrentMark; ysr@777: ysr@777: class ConcurrentMarkThread: public ConcurrentGCThread { ysr@777: friend class VMStructs; ysr@777: ysr@777: double _vtime_start; // Initial virtual time. ysr@777: double _vtime_accum; // Accumulated virtual time. ysr@777: ysr@777: double _vtime_mark_accum; ysr@777: ysr@777: public: ysr@777: virtual void run(); ysr@777: ysr@777: private: ysr@777: ConcurrentMark* _cm; tonyp@1794: volatile bool _started; tonyp@1794: volatile bool _in_progress; ysr@777: ysr@777: void sleepBeforeNextCycle(); ysr@777: ysr@777: static SurrogateLockerThread* _slt; ysr@777: ysr@777: public: ysr@777: // Constructor ysr@777: ConcurrentMarkThread(ConcurrentMark* cm); ysr@777: ysr@777: static void makeSurrogateLockerThread(TRAPS); ysr@777: static SurrogateLockerThread* slt() { return _slt; } ysr@777: ysr@777: // Printing tonyp@1454: void print_on(outputStream* st) const; tonyp@1454: void print() const; ysr@777: ysr@777: // Total virtual time so far. ysr@777: double vtime_accum(); ysr@777: // Marking virtual time so far ysr@777: double vtime_mark_accum(); ysr@777: tonyp@1794: ConcurrentMark* cm() { return _cm; } ysr@777: johnc@2195: void set_started() { assert(!_in_progress, "cycle in progress"); _started = true; } johnc@2195: void clear_started() { assert(_in_progress, "must be starting a cycle"); _started = false; } tonyp@1794: bool started() { return _started; } ysr@777: johnc@2195: void set_in_progress() { assert(_started, "must be starting a cycle"); _in_progress = true; } johnc@2195: void clear_in_progress() { assert(!_started, "must not be starting a new cycle"); _in_progress = false; } tonyp@1794: bool in_progress() { return _in_progress; } tonyp@1794: tonyp@1794: // This flag returns true from the moment a marking cycle is tonyp@1794: // initiated (during the initial-mark pause when started() is set) tonyp@1794: // to the moment when the cycle completes (just after the next tonyp@1794: // marking bitmap has been cleared and in_progress() is tonyp@1794: // cleared). While this flag is true we will not start another cycle tonyp@1794: // so that cycles do not overlap. We cannot use just in_progress() tonyp@1794: // as the CM thread might take some time to wake up before noticing tonyp@1794: // that started() is set and set in_progress(). tonyp@1794: bool during_cycle() { return started() || in_progress(); } ysr@777: ysr@777: // Yield for GC ysr@777: void yield(); ysr@777: ysr@777: // shutdown iveresov@1229: void stop(); ysr@777: }; stefank@2314: stefank@2314: #endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARKTHREAD_HPP