benchmark: Use uatomic for accessing global states
[urcu.git] / tests / benchmark / test_urcu_lfq.c
index 2217760b0f9ae18f56ac887fb6a06f417b710ca4..66cf78ca36aa0e4668e663461cd2c84a7c12f8c6 100644 (file)
@@ -33,8 +33,6 @@
 #include <urcu.h>
 #include <urcu/cds.h>
 
-static volatile int test_go, test_stop;
-
 static unsigned long rduration;
 
 static unsigned long duration;
@@ -96,12 +94,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);
@@ -132,10 +130,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));
@@ -188,10 +183,7 @@ void *thr_dequeuer(void *_count)
 
        rcu_register_thread();
 
-       while (!test_go)
-       {
-       }
-       cmm_smp_mb();
+       wait_until_go();
 
        for (;;) {
                struct cds_lfq_node_rcu *qnode;
@@ -361,7 +353,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);
@@ -371,7 +363,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.023383 seconds and 4 git commands to generate.