< prev index next >

src/share/vm/utilities/yieldingWorkgroup.cpp

Print this page
rev 7793 : 8073315: Enable gcc -Wtype-limits and fix upcoming issues.
Summary: Relevant fixes in blockOffsetTable.cpp, os_linux.cpp, parCardTableModRefBS.cpp.
   1 /*
   2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   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  *


 103   gangs. Once this works well, we will in a second
 104   iteration.refinement introduce flexibility into
 105   the work gang.
 106 
 107 NOTE: we can always create a new gang per each iteration
 108   in order to get the flexibility, but we will for now
 109   desist that simplified route.
 110 
 111  */
 112 /////////////////////
 113 void YieldingFlexibleWorkGang::start_task(YieldingFlexibleGangTask* new_task) {
 114   MutexLockerEx ml(monitor(), Mutex::_no_safepoint_check_flag);
 115   assert(task() == NULL, "Gang currently tied to a task");
 116   assert(new_task != NULL, "Null task");
 117   // Bind task to gang
 118   _task = new_task;
 119   new_task->set_gang(this);  // Establish 2-way binding to support yielding
 120   _sequence_number++;
 121 
 122   uint requested_size = new_task->requested_size();
 123   assert(requested_size >= 0, "Should be non-negative");
 124   if (requested_size != 0) {
 125     _active_workers = MIN2(requested_size, total_workers());
 126   } else {
 127     _active_workers = active_workers();
 128   }
 129   new_task->set_actual_size(_active_workers);
 130   new_task->set_for_termination(_active_workers);
 131 
 132   assert(_started_workers == 0, "Tabula rasa non");
 133   assert(_finished_workers == 0, "Tabula rasa non");
 134   assert(_yielded_workers == 0, "Tabula rasa non");
 135   yielding_task()->set_status(ACTIVE);
 136 
 137   // Wake up all the workers, the first few will get to work,
 138   // and the rest will go back to sleep
 139   monitor()->notify_all();
 140   wait_for_gang();
 141 }
 142 
 143 void YieldingFlexibleWorkGang::wait_for_gang() {


   1 /*
   2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   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  *


 103   gangs. Once this works well, we will in a second
 104   iteration.refinement introduce flexibility into
 105   the work gang.
 106 
 107 NOTE: we can always create a new gang per each iteration
 108   in order to get the flexibility, but we will for now
 109   desist that simplified route.
 110 
 111  */
 112 /////////////////////
 113 void YieldingFlexibleWorkGang::start_task(YieldingFlexibleGangTask* new_task) {
 114   MutexLockerEx ml(monitor(), Mutex::_no_safepoint_check_flag);
 115   assert(task() == NULL, "Gang currently tied to a task");
 116   assert(new_task != NULL, "Null task");
 117   // Bind task to gang
 118   _task = new_task;
 119   new_task->set_gang(this);  // Establish 2-way binding to support yielding
 120   _sequence_number++;
 121 
 122   uint requested_size = new_task->requested_size();

 123   if (requested_size != 0) {
 124     _active_workers = MIN2(requested_size, total_workers());
 125   } else {
 126     _active_workers = active_workers();
 127   }
 128   new_task->set_actual_size(_active_workers);
 129   new_task->set_for_termination(_active_workers);
 130 
 131   assert(_started_workers == 0, "Tabula rasa non");
 132   assert(_finished_workers == 0, "Tabula rasa non");
 133   assert(_yielded_workers == 0, "Tabula rasa non");
 134   yielding_task()->set_status(ACTIVE);
 135 
 136   // Wake up all the workers, the first few will get to work,
 137   // and the rest will go back to sleep
 138   monitor()->notify_all();
 139   wait_for_gang();
 140 }
 141 
 142 void YieldingFlexibleWorkGang::wait_for_gang() {


< prev index next >