Fix phase5 test log collection
[urcu.git] / test_urcu_gc.c
index f1cce248a8b604709ffcb9e3a265c1f983bc03f7..12ea1811173f3520d36b420de05c09da17e280a2 100644 (file)
@@ -105,22 +105,33 @@ static unsigned int cpu_affinities[NR_CPUS];
 static unsigned int next_aff = 0;
 static int use_affinity = 0;
 
+pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER;
+
 static void set_affinity(void)
 {
        cpu_set_t mask;
        int cpu;
+       int ret;
 
        if (!use_affinity)
                return;
 
+       ret = pthread_mutex_lock(&affinity_mutex);
+       if (ret) {
+               perror("Error in pthread mutex lock");
+               exit(-1);
+       }
        cpu = cpu_affinities[next_aff++];
+       ret = pthread_mutex_unlock(&affinity_mutex);
+       if (ret) {
+               perror("Error in pthread mutex unlock");
+               exit(-1);
+       }
        CPU_ZERO(&mask);
        CPU_SET(cpu, &mask);
        sched_setaffinity(0, sizeof(mask), &mask);
 }
 
-
-
 /*
  * returns 0 if test should end.
  */
@@ -240,7 +251,11 @@ static void rcu_gc_reclaim(unsigned long wtidx, void *old)
 void *thr_writer(void *data)
 {
        unsigned long wtidx = (unsigned long)data;
+#ifdef TEST_LOCAL_GC
+       struct test_array *old = NULL;
+#else
        struct test_array *new, *old;
+#endif
 
        printf_verbose("thread_begin %s, thread id : %lx, tid %lu\n",
                        "writer", pthread_self(), (unsigned long)gettid());
@@ -253,14 +268,11 @@ void *thr_writer(void *data)
        smp_mb();
 
        for (;;) {
+#ifndef TEST_LOCAL_GC
                new = malloc(sizeof(*new));
-               rcu_copy_mutex_lock();
-               old = test_rcu_pointer;
-               if (old)
-                       assert(old->a == 8);
                new->a = 8;
                old = rcu_xchg_pointer(&test_rcu_pointer, new);
-               rcu_copy_mutex_unlock();
+#endif
                rcu_gc_reclaim(wtidx, old);
                nr_writes++;
                if (unlikely(!test_duration_write()))
This page took 0.023211 seconds and 4 git commands to generate.