benchmark: Use uatomic for accessing global states
[urcu.git] / tests / benchmark / test_urcu_lfs_rcu.c
index 7aabc1d3370a1a6acd942b57d757b990b89bd1d9..cb9236d87d05a0209b3392a1aa47a34345c612f9 100644 (file)
@@ -37,8 +37,6 @@
 
 #include <urcu/cds.h>
 
-static volatile int test_go, test_stop;
-
 static unsigned long rduration;
 
 static unsigned long duration;
@@ -100,12 +98,12 @@ static void set_affinity(void)
  */
 static int test_duration_dequeue(void)
 {
-       return !test_stop;
+       return test_duration_read();
 }
 
 static int test_duration_enqueue(void)
 {
-       return !test_stop;
+       return test_duration_write();
 }
 
 static DEFINE_URCU_TLS(unsigned long long, nr_dequeues);
@@ -136,10 +134,7 @@ void *thr_enqueuer(void *_count)
 
        rcu_register_thread();
 
-       while (!test_go)
-       {
-       }
-       cmm_smp_mb();
+       wait_until_go();
 
        for (;;) {
                struct test *node = malloc(sizeof(*node));
@@ -191,10 +186,7 @@ void *thr_dequeuer(void *_count)
 
        rcu_register_thread();
 
-       while (!test_go)
-       {
-       }
-       cmm_smp_mb();
+       wait_until_go();
 
        for (;;) {
                struct cds_lfs_node_rcu *snode;
@@ -363,7 +355,7 @@ int main(int argc, char **argv)
 
        cmm_smp_mb();
 
-       test_go = 1;
+       begin_test();
 
        for (i_thr = 0; i_thr < duration; i_thr++) {
                sleep(1);
@@ -373,7 +365,7 @@ int main(int argc, char **argv)
                }
        }
 
-       test_stop = 1;
+       end_test();
 
        for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
                err = pthread_join(tid_enqueuer[i_thr], &tret);
This page took 0.023091 seconds and 4 git commands to generate.