2 #include "cds_threads.h"
6 /* For data race instrumentation */
9 struct mcs_mutex *mutex;
10 static uint32_t shared;
12 void threadA(void *arg)
14 // std::this_thread::sleep_for(std::chrono::milliseconds(10));
15 mcs_mutex::guard g(mutex);
16 printf("store: %d\n", 17);
17 store_32(&shared, 17);
20 printf("load: %u\n", load_32(&shared));
23 void threadB(void *arg)
25 // std::this_thread::sleep_for(std::chrono::milliseconds(10));
26 mcs_mutex::guard g(mutex);
27 printf("load: %u\n", load_32(&shared));
30 printf("store: %d\n", 17);
31 store_32(&shared, 17);
34 int user_main(int argc, char **argv)
36 mutex = new mcs_mutex();
38 std::thread A(threadA, (void *)NULL);
39 std::thread B(threadB, (void *)NULL);