--- /dev/null
+#include "common.h"
+#include <atomic>
+#include <cds/gc/dhp.h>
+#include <cds/gc/hp.h>
+#include <cds/sync/mcs-lock.h>
+#include <cds_test/stress_test.h>
+#include <iostream>
+#include <memory>
+#include <thread>
+
+using namespace std;
+
+namespace {
+
+static size_t s_nMCSLockThreadCount = 6;
+static size_t s_nMCSLockPassCount = 3000000;
+
+class MCSLockTest : public cds_test::stress_fixture {
+protected:
+ static ullong x;
+ static cds_others::mcs_mutex *my_mutex;
+
+ static void SetUpTestCase() {
+ cds_test::config const &cfg = get_config("SequentialMisc");
+ GetConfig(MCSLockPassCount);
+ GetConfig(MCSLockThreadCount);
+ }
+
+ static void Thread() {
+ cds_others::mcs_mutex::guard g(my_mutex);
+ my_mutex->unlock(&g);
+ for (ullong i = 0; i < s_nMCSLockPassCount; i++) {
+ my_mutex->lock(&g);
+ x++;
+ my_mutex->unlock(&g);
+ }
+ my_mutex->lock(&g);
+ }
+};
+
+ullong MCSLockTest::x;
+cds_others::mcs_mutex *MCSLockTest::my_mutex;
+
+TEST_F(MCSLockTest, MCSLock) {
+ my_mutex = new cds_others::mcs_mutex();
+ cds_others::mcs_mutex::guard g(my_mutex);
+ my_mutex->unlock(&g);
+ for (size_t i = 0; i < s_nMCSLockPassCount; i++) {
+ my_mutex->lock(&g);
+ x++;
+ my_mutex->unlock(&g);
+ }
+ my_mutex->lock(&g);
+}
+
+} // namespace