< prev index next >

src/hotspot/share/runtime/task.cpp

Print this page
rev 56464 : 8231707: Improve Mutex inlining
Contributed-by: robbin.ehn@oracle.com, claes.redestad@oracle.com


   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 "memory/allocation.hpp"
  27 #include "runtime/init.hpp"

  28 #include "runtime/task.hpp"
  29 #include "runtime/thread.inline.hpp"
  30 #include "runtime/timer.hpp"
  31 
  32 int PeriodicTask::_num_tasks = 0;
  33 PeriodicTask* PeriodicTask::_tasks[PeriodicTask::max_tasks];
  34 
  35 void PeriodicTask::real_time_tick(int delay_time) {
  36   assert(Thread::current()->is_Watcher_thread(), "must be WatcherThread");
  37 
  38   // The WatcherThread does not participate in the safepoint protocol
  39   // for the PeriodicTask_lock because it is not a JavaThread.
  40   MutexLocker ml(PeriodicTask_lock, Mutex::_no_safepoint_check_flag);
  41   int orig_num_tasks = _num_tasks;
  42 
  43   for(int index = 0; index < _num_tasks; index++) {
  44     _tasks[index]->execute_if_pending(delay_time);
  45     if (_num_tasks < orig_num_tasks) { // task dis-enrolled itself
  46       index--;  // re-do current slot as it has changed
  47       orig_num_tasks = _num_tasks;




   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 "memory/allocation.hpp"
  27 #include "runtime/init.hpp"
  28 #include "runtime/mutexLocker.inline.hpp"
  29 #include "runtime/task.hpp"
  30 #include "runtime/thread.inline.hpp"
  31 #include "runtime/timer.hpp"
  32 
  33 int PeriodicTask::_num_tasks = 0;
  34 PeriodicTask* PeriodicTask::_tasks[PeriodicTask::max_tasks];
  35 
  36 void PeriodicTask::real_time_tick(int delay_time) {
  37   assert(Thread::current()->is_Watcher_thread(), "must be WatcherThread");
  38 
  39   // The WatcherThread does not participate in the safepoint protocol
  40   // for the PeriodicTask_lock because it is not a JavaThread.
  41   MutexLocker ml(PeriodicTask_lock, Mutex::_no_safepoint_check_flag);
  42   int orig_num_tasks = _num_tasks;
  43 
  44   for(int index = 0; index < _num_tasks; index++) {
  45     _tasks[index]->execute_if_pending(delay_time);
  46     if (_num_tasks < orig_num_tasks) { // task dis-enrolled itself
  47       index--;  // re-do current slot as it has changed
  48       orig_num_tasks = _num_tasks;


< prev index next >