X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=test%2Flitmus%2Firiw.cc;h=fa4a0341049a2a07f66c72c040db8ed54e3cd39f;hb=2935d5ce8b7315c0b13306b15ac18beeacfc37bb;hp=80ee8b90f77ecd2ba3aa5f8e41b48b5f9017343f;hpb=1b0df15c23ebf67b7737021312dbb14bf442daba;p=model-checker.git diff --git a/test/litmus/iriw.cc b/test/litmus/iriw.cc index 80ee8b9..fa4a034 100644 --- a/test/litmus/iriw.cc +++ b/test/litmus/iriw.cc @@ -5,32 +5,39 @@ std::atomic_int x; std::atomic_int y; +std::memory_order store_mo = std::memory_order_release; +std::memory_order load_mo = std::memory_order_acquire; + static void a(void *obj) { - x.store(1, std::memory_order_release); + x.store(1, store_mo); } static void b(void *obj) { - y.store(1, std::memory_order_release); + y.store(1, store_mo); } static void c(void *obj) { - printf("x1: %d\n", x.load(std::memory_order_acquire)); - printf("y1: %d\n", y.load(std::memory_order_acquire)); + printf("x1: %d\n", x.load(load_mo)); + printf("y1: %d\n", y.load(load_mo)); } static void d(void *obj) { - printf("y2: %d\n", y.load(std::memory_order_acquire)); - printf("x2: %d\n", x.load(std::memory_order_acquire)); + printf("y2: %d\n", y.load(load_mo)); + printf("x2: %d\n", x.load(load_mo)); } int user_main(int argc, char **argv) { thrd_t t1, t2, t3, t4; + /* Command-line argument 's' enables seq_cst test */ + if (argc > 1 && *argv[1] == 's') + store_mo = load_mo = std::memory_order_seq_cst; + atomic_init(&x, 0); atomic_init(&y, 0);