From: Peizhao Ou Date: Wed, 19 Mar 2014 03:51:08 +0000 (-0700) Subject: save X-Git-Url: http://plrg.eecs.uci.edu/git/?p=cdsspec-compiler.git;a=commitdiff_plain;h=f4f705b64671cdfae4d4cf8997e64a81ddce201d save --- diff --git a/benchmark/linuxrwlocks/linuxrwlocks.c b/benchmark/linuxrwlocks/linuxrwlocks.c index c7ef94c..eaae816 100644 --- a/benchmark/linuxrwlocks/linuxrwlocks.c +++ b/benchmark/linuxrwlocks/linuxrwlocks.c @@ -293,16 +293,36 @@ static void a(void *obj) for(i = 0; i < 2; i++) { if ((i % 2) == 0) { read_lock(&mylock); - load_32(&shareddata); + //load_32(&shareddata); + printf("%d\n", shareddata); read_unlock(&mylock); } else { write_lock(&mylock); - store_32(&shareddata,(unsigned int)i); + //store_32(&shareddata,(unsigned int)i); + shareddata = 47; write_unlock(&mylock); } } } +static void b(void *obj) +{ + int i; + for(i = 0; i < 2; i++) { + if ((i % 2) == 0) { + if (read_trylock(&mylock) == 1) { + printf("%d\n", shareddata); + read_unlock(&mylock); + } + } else { + if (write_trylock(&mylock) == 1) { + shareddata = 47; + write_unlock(&mylock); + } + } + } +} + int user_main(int argc, char **argv) { /** @@ -314,7 +334,7 @@ int user_main(int argc, char **argv) atomic_init(&mylock.lock, RW_LOCK_BIAS); thrd_create(&t1, (thrd_start_t)&a, NULL); - thrd_create(&t2, (thrd_start_t)&a, NULL); + thrd_create(&t2, (thrd_start_t)&b, NULL); thrd_join(t1); thrd_join(t2); diff --git a/benchmark/read-copy-update/rcu.cc b/benchmark/read-copy-update/rcu.cc index 6f79126..3b49559 100644 --- a/benchmark/read-copy-update/rcu.cc +++ b/benchmark/read-copy-update/rcu.cc @@ -87,7 +87,7 @@ void write(Data *new_data) { bool succ = false; do { succ = data.compare_exchange_strong(prev, new_data, - memory_order_release, memory_order_relaxed); + memory_order_acq_rel, memory_order_relaxed); /** @Begin @Commit_point_define_check: succ