< prev index next >

src/share/vm/runtime/mutex.cpp

Print this page


   1 
   2 /*
   3  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *


1356         prev->_next = _next;
1357       }
1358       _next = NULL;
1359     #endif
1360   }
1361 }
1362 
1363 
1364 // Factored out common sanity checks for locking mutex'es. Used by lock() and try_lock()
1365 void Monitor::check_prelock_state(Thread *thread) {
1366   assert((!thread->is_Java_thread() || ((JavaThread *)thread)->thread_state() == _thread_in_vm)
1367          || rank() == Mutex::special, "wrong thread state for using locks");
1368   if (StrictSafepointChecks) {
1369     if (thread->is_VM_thread() && !allow_vm_block()) {
1370       fatal(err_msg("VM thread using lock %s (not allowed to block on)",
1371                     name()));
1372     }
1373     debug_only(if (rank() != Mutex::special) \
1374       thread->check_for_valid_safepoint_state(false);)
1375   }
1376   if (thread->is_Watcher_thread()) {
1377     assert(!WatcherThread::watcher_thread()->has_crash_protection(),
1378         "locking not allowed when crash protection is set");
1379   }
1380 }
1381 
1382 void Monitor::check_block_state(Thread *thread) {
1383   if (!_allow_vm_block && thread->is_VM_thread()) {
1384     warning("VM thread blocked on lock");
1385     print();
1386     BREAKPOINT;
1387   }
1388   assert(_owner != thread, "deadlock: blocking on monitor owned by current thread");
1389 }
1390 
1391 #endif // PRODUCT
   1 
   2 /*
   3  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *


1356         prev->_next = _next;
1357       }
1358       _next = NULL;
1359     #endif
1360   }
1361 }
1362 
1363 
1364 // Factored out common sanity checks for locking mutex'es. Used by lock() and try_lock()
1365 void Monitor::check_prelock_state(Thread *thread) {
1366   assert((!thread->is_Java_thread() || ((JavaThread *)thread)->thread_state() == _thread_in_vm)
1367          || rank() == Mutex::special, "wrong thread state for using locks");
1368   if (StrictSafepointChecks) {
1369     if (thread->is_VM_thread() && !allow_vm_block()) {
1370       fatal(err_msg("VM thread using lock %s (not allowed to block on)",
1371                     name()));
1372     }
1373     debug_only(if (rank() != Mutex::special) \
1374       thread->check_for_valid_safepoint_state(false);)
1375   }
1376   assert(!os::ThreadCrashProtection::is_crash_protected(thread),
1377          "locking not allowed when crash protection is set");


1378 }
1379 
1380 void Monitor::check_block_state(Thread *thread) {
1381   if (!_allow_vm_block && thread->is_VM_thread()) {
1382     warning("VM thread blocked on lock");
1383     print();
1384     BREAKPOINT;
1385   }
1386   assert(_owner != thread, "deadlock: blocking on monitor owned by current thread");
1387 }
1388 
1389 #endif // PRODUCT
< prev index next >