668N/A * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 668N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 668N/A * This code is free software; you can redistribute it and/or modify it 668N/A * under the terms of the GNU General Public License version 2 only, as 668N/A * published by the Free Software Foundation. 668N/A * This code is distributed in the hope that it will be useful, but WITHOUT 668N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 668N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 668N/A * version 2 for more details (a copy is included in the LICENSE file that 668N/A * accompanied this code). 668N/A * You should have received a copy of the GNU General Public License version 668N/A * 2 along with this work; if not, write to the Free Software Foundation, 668N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 668N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA // ======= Concurrent Mark Sweep Thread ======== // The CMS thread is created when Concurrent Mark Sweep is used in the // older of two generations in a generational memory system. // When icms is enabled, the icms thread is stopped until explicitly set_name(
"Concurrent Mark-Sweep GC Thread");
// An old comment here said: "Priority should be just less // than that of VMThread". Since the VMThread runs at // NearMaxPriority, the old comment was inaccurate, but // changing the default priority to NearMaxPriority-1 // could change current behavior, so the default of // NearMaxPriority stays in place. // Note that there's a possibility of the VMThread // starving if UseCriticalCMSThreadPriority is on. // That won't happen on Solaris for various reasons, // but may well happen on non-Solaris platforms. // From this time Thread::current() should be working. // Wait until Universe::is_fully_initialized() "Universe::is_fully_initialized()",
2);
// Wait until Universe is initialized and all initialization is completed. // Wait until the surrogate locker thread that will do // pending list locking on our behalf has been created. // We cannot start the SLT thread ourselves since we need // to be a JavaThread to do so. // Check that the state of any protocol for synchronization // between background (CMS) and foreground collector is "clean" // (i.e. will not potentially block the foreground collector, // requiring action by us). // Signal that it is terminated // Thread destructor usually does this.. "Must renounce all worldly possessions and desires for nirvana");
// create and start a new ConcurrentMarkSweep Thread for given CMS generation assert(
cmst() ==
th,
"Where did the just-created CMS thread go?");
// Disable incremental mode and wake up the thread so it notices the change. // it is ok to take late safepoints here, if needed {
// Now post a notify on CGC_lock so as to nudge // CMS thread(s) that might be slumbering in {
// Now wait until (all) CMS thread(s) have exited "Called too early, make sure heap is fully initialized");
// indicate that we want to get the token // claim the token and proceed // The following barrier assumes there's only one CMS thread. // This will need to be modified is there are more CMS threads than one. // wake-up a waiting CMS thread "Should have been cleared");
// wake-up a waiting VM thread "Should have been cleared");
// Wait until the next synchronous GC, a concurrent full gc request, // or a timeout, whichever is earlier. // Wait until the next synchronous GC, a concurrent full gc // request or a timeout, whichever is earlier. // Check if we should start a CMS collection cycle // .. collection criterion not yet met, let's go back // Note: this method, although exported by the ConcurrentMarkSweepThread, // which is a non-JavaThread, can only be called by a JavaThread. // Currently this is done at vm creation time (post-vm-init) by the // XXX Consider changing this in the future to allow the CMS thread // itself to create this thread?