ysr@777: /* stefank@2314: * Copyright (c) 2001, 2010, 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_CONCURRENTG1REFINETHREAD_HPP stefank@2314: #define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINETHREAD_HPP stefank@2314: stefank@2314: #include "gc_implementation/shared/concurrentGCThread.hpp" stefank@2314: ysr@777: // Forward Decl. ysr@777: class ConcurrentG1Refine; ysr@777: ysr@777: // The G1 Concurrent Refinement Thread (could be several in the future). ysr@777: ysr@777: class ConcurrentG1RefineThread: public ConcurrentGCThread { ysr@777: friend class VMStructs; ysr@777: friend class G1CollectedHeap; ysr@777: ysr@777: double _vtime_start; // Initial virtual time. ysr@777: double _vtime_accum; // Initial virtual time. iveresov@1229: int _worker_id; iveresov@1230: int _worker_id_offset; ysr@777: iveresov@1229: // The refinement threads collection is linked list. A predecessor can activate a successor iveresov@1229: // when the number of the rset update buffer crosses a certain threshold. A successor iveresov@1229: // would self-deactivate when the number of the buffers falls below the threshold. iveresov@1229: bool _active; iveresov@1546: ConcurrentG1RefineThread* _next; iveresov@1546: Monitor* _monitor; iveresov@1546: ConcurrentG1Refine* _cg1r; ysr@777: iveresov@1546: int _thread_threshold_step; iveresov@1546: // This thread activation threshold iveresov@1546: int _threshold; iveresov@1546: // This thread deactivation threshold iveresov@1546: int _deactivation_threshold; iveresov@1229: iveresov@1546: void sample_young_list_rs_lengths(); iveresov@1546: void run_young_rs_sampling(); iveresov@1546: void wait_for_completed_buffers(); ysr@777: iveresov@1546: void set_active(bool x) { _active = x; } iveresov@1546: bool is_active(); iveresov@1546: void activate(); iveresov@1546: void deactivate(); ysr@777: ysr@777: // For use by G1CollectedHeap, which is a friend. ysr@777: static SuspendibleThreadSet* sts() { return &_sts; } ysr@777: iveresov@1546: public: iveresov@1546: virtual void run(); ysr@777: // Constructor iveresov@1230: ConcurrentG1RefineThread(ConcurrentG1Refine* cg1r, ConcurrentG1RefineThread* next, iveresov@1230: int worker_id_offset, int worker_id); ysr@777: iveresov@1546: void initialize(); iveresov@1546: ysr@777: // Printing tonyp@1454: void print() const; tonyp@1454: void print_on(outputStream* st) const; ysr@777: ysr@777: // Total virtual time so far. ysr@777: double vtime_accum() { return _vtime_accum; } ysr@777: iveresov@1546: ConcurrentG1Refine* cg1r() { return _cg1r; } ysr@777: ysr@777: // Yield for GC iveresov@1546: void yield(); ysr@777: // shutdown iveresov@1229: void stop(); ysr@777: }; stefank@2314: stefank@2314: #endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINETHREAD_HPP