< prev index next >

test/hotspot/gtest/utilities/test_singleWriterSynchronizer.cpp

Print this page

        

*** 22,32 **** * */ #include "precompiled.hpp" #include "runtime/interfaceSupport.inline.hpp" ! #include "runtime/orderAccess.hpp" #include "runtime/os.hpp" #include "runtime/thread.hpp" #include "utilities/debug.hpp" #include "utilities/globalCounter.inline.hpp" #include "utilities/globalDefinitions.hpp" --- 22,32 ---- * */ #include "precompiled.hpp" #include "runtime/interfaceSupport.inline.hpp" ! #include "runtime/atomic.hpp" #include "runtime/os.hpp" #include "runtime/thread.hpp" #include "utilities/debug.hpp" #include "utilities/globalCounter.inline.hpp" #include "utilities/globalDefinitions.hpp"
*** 54,71 **** {} virtual void main_run() { size_t iterations = 0; size_t values_changed = 0; ! while (OrderAccess::load_acquire(_continue_running) != 0) { { ThreadBlockInVM tbiv(this); } // Safepoint check outside critical section. ++iterations; SingleWriterSynchronizer::CriticalSection cs(_synchronizer); ! uintx value = OrderAccess::load_acquire(_synchronized_value); uintx new_value = value; for (uint i = 0; i < reader_iterations; ++i) { ! new_value = OrderAccess::load_acquire(_synchronized_value); // A reader can see either the value it first read after // entering the critical section, or that value + 1. No other // values are possible. if (value != new_value) { ASSERT_EQ((value + 1), new_value); --- 54,71 ---- {} virtual void main_run() { size_t iterations = 0; size_t values_changed = 0; ! while (Atomic::load_acquire(_continue_running) != 0) { { ThreadBlockInVM tbiv(this); } // Safepoint check outside critical section. ++iterations; SingleWriterSynchronizer::CriticalSection cs(_synchronizer); ! uintx value = Atomic::load_acquire(_synchronized_value); uintx new_value = value; for (uint i = 0; i < reader_iterations; ++i) { ! new_value = Atomic::load_acquire(_synchronized_value); // A reader can see either the value it first read after // entering the critical section, or that value + 1. No other // values are possible. if (value != new_value) { ASSERT_EQ((value + 1), new_value);
*** 95,105 **** _synchronized_value(synchronized_value), _continue_running(continue_running) {} virtual void main_run() { ! while (OrderAccess::load_acquire(_continue_running) != 0) { ++*_synchronized_value; _synchronizer->synchronize(); { ThreadBlockInVM tbiv(this); } // Safepoint check. } tty->print_cr("writer iterations: " UINTX_FORMAT, *_synchronized_value); --- 95,105 ---- _synchronized_value(synchronized_value), _continue_running(continue_running) {} virtual void main_run() { ! while (Atomic::load_acquire(_continue_running) != 0) { ++*_synchronized_value; _synchronizer->synchronize(); { ThreadBlockInVM tbiv(this); } // Safepoint check. } tty->print_cr("writer iterations: " UINTX_FORMAT, *_synchronized_value);
< prev index next >