taskqueue.cpp revision 1472
1008N/A * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved. 1008N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1008N/A * This code is free software; you can redistribute it and/or modify it 1008N/A * under the terms of the GNU General Public License version 2 only, as 1008N/A * published by the Free Software Foundation. 1008N/A * This code is distributed in the hope that it will be useful, but WITHOUT 1008N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1008N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1008N/A * version 2 for more details (a copy is included in the LICENSE file that 1008N/A * You should have received a copy of the GNU General Public License version 1008N/A * 2 along with this work; if not, write to the Free Software Foundation, 1008N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1008N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1008N/A#
include "incls/_precompiled.incl" 1008N/A const int q =
127773;
/* m div a */ 1008N/A const int r =
2836;
/* m mod a */ 1548N/A // Number of hard spin loops done since last yield 1548N/A // Number of iterations in the hard spin loop. 1548N/A // If WorkStealingSpinToYieldRatio is 0, no hard spinning is done. 1548N/A // If it is greater than 0, then start with a small number 1548N/A // of spins and increase number with each turn at spinning until 1548N/A // the count of hard spins exceeds WorkStealingSpinToYieldRatio. 1548N/A // Then do a yield() call and start spinning afresh. 1548N/A // Remember the initial spin limit. 1548N/A // Loop waiting for all threads to offer termination or 1548N/A // Are all threads offering termination? 1008N/A // Periodically sleep() instead of yield() to give threads 1008N/A // waiting on the cores the chance to grab this code 1008N/A // Do a yield or hardspin. For purposes of deciding whether 1008N/A // to sleep, count this as a yield. 1008N/A // Periodically call yield() instead spinning 1008N/A // After WorkStealingSpinToYieldRatio spins, do a yield() call 1008N/A // and reset the counts and starting limit. 1008N/A // Increase the hard spinning period but only up to a limit. 1008N/A "thread %d sleeps after %d yields",
1008N/A // A sleep will cause this processor to seek work on another processor's 1008N/A // runqueue, if it has nothing else to run (as opposed to the yield 1426N/A // which may only move the thread to the end of the this processor's 1008N/A "Total spins: %lld Total peeks: %lld",
1008N/A "Terminator may still be in use");
1008N/A// Note that using this method will retrieve all regions 1008N/A// that have been saved but that it will always check 1008N/A// the overflow stack. It may be more efficient to 1008N/A// check the stealable queue and the overflow stack