Refactors lock test cases backoff values
authorPeizhao Ou <peizhaoo@uci.edu>
Tue, 30 Jan 2018 08:45:41 +0000 (00:45 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Tue, 30 Jan 2018 08:45:41 +0000 (00:45 -0800)
cds/misc/mcs-lock.h
test/stress/misc/CMakeLists.txt
test/stress/misc/backoff.cpp [new file with mode: 0644]
test/stress/sequential/sequential-misc/CMakeLists.txt
test/stress/sequential/sequential-misc/backoff.cpp [new file with mode: 0644]
test/stress/sequential/sequential-misc/mcslock_driver.cpp

index d5cda3a..a6eb04e 100644 (file)
@@ -8,9 +8,6 @@
 
 namespace cds_others {
 
-size_t BackoffTraits::lower_bound = 16;
-size_t BackoffTraits::upper_bound = 1024;
-
 // Forward declaration
 struct mcs_node;
 struct mcs_mutex;
index 4373871..8d15dd9 100644 (file)
@@ -8,6 +8,7 @@ set(CDSSTRESS_STACK_SOURCES
     seqlock_driver.cpp
     rwlock_driver.cpp
     mcslock_driver.cpp
+    backoff.cpp
 )
 
 include_directories(
diff --git a/test/stress/misc/backoff.cpp b/test/stress/misc/backoff.cpp
new file mode 100644 (file)
index 0000000..85c014c
--- /dev/null
@@ -0,0 +1,15 @@
+#include "common.h"
+#include <atomic>
+#include <cds/gc/dhp.h>
+#include <cds/gc/hp.h>
+#include <cds/misc/backoff.h>
+#include <cds_test/stress_test.h>
+#include <iostream>
+#include <memory>
+
+namespace cds_others {
+
+size_t BackoffTraits::lower_bound = 16;
+size_t BackoffTraits::upper_bound = 1024;
+
+} // namespace cds_others
index 15646c6..a6f0064 100644 (file)
@@ -1,6 +1,6 @@
 set(PACKAGE_NAME stress-sequential-misc)
 
-set(CDSSTRESS_STACK_SOURCES
+set(CDSSTRESS_MISC_SOURCES
     main.cpp
     rigtorp_spsc_driver.cpp
     rigtorp_mpmc_driver.cpp
@@ -9,13 +9,14 @@ set(CDSSTRESS_STACK_SOURCES
     seqlock_driver.cpp
     rwlock_driver.cpp
     mcslock_driver.cpp
+    backoff.cpp
 )
 
 include_directories(
     ${CMAKE_CURRENT_SOURCE_DIR}
 )
 
-add_executable(${PACKAGE_NAME} ${CDSSTRESS_STACK_SOURCES})
+add_executable(${PACKAGE_NAME} ${CDSSTRESS_MISC_SOURCES})
 target_link_libraries(${PACKAGE_NAME} ${CDS_TEST_LIBRARIES} ${CDSSTRESS_FRAMEWORK_LIBRARY})
 
 add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
diff --git a/test/stress/sequential/sequential-misc/backoff.cpp b/test/stress/sequential/sequential-misc/backoff.cpp
new file mode 100644 (file)
index 0000000..85c014c
--- /dev/null
@@ -0,0 +1,15 @@
+#include "common.h"
+#include <atomic>
+#include <cds/gc/dhp.h>
+#include <cds/gc/hp.h>
+#include <cds/misc/backoff.h>
+#include <cds_test/stress_test.h>
+#include <iostream>
+#include <memory>
+
+namespace cds_others {
+
+size_t BackoffTraits::lower_bound = 16;
+size_t BackoffTraits::upper_bound = 1024;
+
+} // namespace cds_others
index 576193f..a4a9d17 100644 (file)
@@ -29,6 +29,8 @@ protected:
 ullong MCSLockTest::x;
 
 TEST_F(MCSLockTest, MCSLock) {
+  cds_others::BackoffTraits::lower_bound = 16;
+  cds_others::BackoffTraits::upper_bound = 1024;
   std::unique_ptr<cds_others::mcs_mutex> my_mutex(new cds_others::mcs_mutex());
   cds_others::mcs_mutex::guard g(my_mutex.get());
   my_mutex->unlock(&g);