8 std::memory_order store_mo = std::memory_order_release;
9 std::memory_order load_mo = std::memory_order_acquire;
11 static void a(void *obj)
16 static void b(void *obj)
21 static void c(void *obj)
23 printf("x1: %d\n", x.load(load_mo));
24 printf("y1: %d\n", y.load(load_mo));
27 static void d(void *obj)
29 printf("y2: %d\n", y.load(load_mo));
30 printf("x2: %d\n", x.load(load_mo));
33 int user_main(int argc, char **argv)
35 thrd_t t1, t2, t3, t4;
37 /* Command-line argument 's' enables seq_cst test */
38 if (argc > 1 && *argv[1] == 's')
39 store_mo = load_mo = std::memory_order_seq_cst;
44 printf("Main thread: creating 4 threads\n");
45 thrd_create(&t1, (thrd_start_t)&a, NULL);
46 thrd_create(&t2, (thrd_start_t)&b, NULL);
47 thrd_create(&t3, (thrd_start_t)&c, NULL);
48 thrd_create(&t4, (thrd_start_t)&d, NULL);
54 printf("Main thread is finished\n");