Refactors test cases
authorPeizhao Ou <peizhaoo@uci.edu>
Thu, 15 Feb 2018 01:06:40 +0000 (17:06 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Thu, 15 Feb 2018 01:06:40 +0000 (17:06 -0800)
test/stress/misc/deque_driver.cpp
test/stress/misc/spinlock_driver.cpp

index 7d933ad3f67f7808b8824a81b478f2dabb6e3a5d..e7d78969851548ceccade843805ca6670fb8f351 100644 (file)
@@ -31,7 +31,7 @@ protected:
   }
 
   static void StealerThread(int index) {
   }
 
   static void StealerThread(int index) {
-    while (!terminate_stealer.load(memory_order_relaxed)) {
+    while (!terminate_stealer.load(memory_order_acquire)) {
       while (true) {
         int res = deque->steal();
         if (res != EMPTY && res != ABORT) {
       while (true) {
         int res = deque->steal();
         if (res != EMPTY && res != ABORT) {
@@ -97,7 +97,7 @@ TEST_F(ChaseLevDequeTest, DequePushPopTake) {
     MainThread(s_nDequeStealerThreadCount, i);
   }
 
     MainThread(s_nDequeStealerThreadCount, i);
   }
 
-  terminate_stealer.store(1, memory_order_relaxed);
+  terminate_stealer.store(1, memory_order_release);
   for (ullong i = 0; i < s_nDequeStealerThreadCount; i++) {
     threads[i].join();
   }
   for (ullong i = 0; i < s_nDequeStealerThreadCount; i++) {
     threads[i].join();
   }
index 4a8eb35bbabdea6fd61976dda9da1d4747ccfcb9..6bccc11739edd84ad478406b8867fc3c541ec4ce 100644 (file)
@@ -20,6 +20,7 @@ typedef cds::sync::reentrant_spin32 Reentrant32;
 typedef cds::sync::reentrant_spin64 Reentrant64;
 static size_t s_nSpinLockThreadCount = 4;
 static size_t s_nSpinLockPassCount = 2500000000;
 typedef cds::sync::reentrant_spin64 Reentrant64;
 static size_t s_nSpinLockThreadCount = 4;
 static size_t s_nSpinLockPassCount = 2500000000;
+static size_t s_nReentrantLockPassCount = 2500000000;
 static size_t s_nTicketLockPassCount = 4000000;
 
 #define TASK(lock_type, lock_ptr, pass_cnt)                                    \
 static size_t s_nTicketLockPassCount = 4000000;
 
 #define TASK(lock_type, lock_ptr, pass_cnt)                                    \
@@ -64,13 +65,14 @@ protected:
     cds_test::config const &cfg = get_config("Misc");
     GetConfig(SpinLockThreadCount);
     GetConfig(SpinLockPassCount);
     cds_test::config const &cfg = get_config("Misc");
     GetConfig(SpinLockThreadCount);
     GetConfig(SpinLockPassCount);
+    GetConfig(ReentrantLockPassCount);
     GetConfig(TicketLockPassCount);
   }
 
   TASK(TicketLock, ticket_mutex, s_nTicketLockPassCount)
   TASK(SpinLock, spin_mutex, s_nSpinLockPassCount)
     GetConfig(TicketLockPassCount);
   }
 
   TASK(TicketLock, ticket_mutex, s_nTicketLockPassCount)
   TASK(SpinLock, spin_mutex, s_nSpinLockPassCount)
-  TASK(Reentrant32, reentrant_mutex32, s_nSpinLockPassCount)
-  TASK(Reentrant64, reentrant_mutex64, s_nSpinLockPassCount)
+  TASK(Reentrant32, reentrant_mutex32, s_nReentrantLockPassCount)
+  TASK(Reentrant64, reentrant_mutex64, s_nReentrantLockPassCount)
 };
 
 size_t SpinLockTest::x;
 };
 
 size_t SpinLockTest::x;
@@ -81,7 +83,7 @@ Reentrant64 *SpinLockTest::reentrant_mutex64;
 
 LOCK_TEST(TicketLock, ticket_mutex, s_nTicketLockPassCount)
 LOCK_TEST(SpinLock, spin_mutex, s_nSpinLockPassCount)
 
 LOCK_TEST(TicketLock, ticket_mutex, s_nTicketLockPassCount)
 LOCK_TEST(SpinLock, spin_mutex, s_nSpinLockPassCount)
-LOCK_TEST(Reentrant32, reentrant_mutex32, s_nSpinLockPassCount)
-LOCK_TEST(Reentrant64, reentrant_mutex64, s_nSpinLockPassCount)
+LOCK_TEST(Reentrant32, reentrant_mutex32, s_nReentrantLockPassCount)
+LOCK_TEST(Reentrant64, reentrant_mutex64, s_nReentrantLockPassCount)
 
 } // namespace
 
 } // namespace