*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/* read-side C.S. duration, in loops */
static unsigned long rduration;
/* read-side C.S. duration, in loops */
static unsigned long rduration;
-static inline void loop_sleep(unsigned long l)
+/* write-side C.S. duration, in loops */
+static unsigned long wduration;
+
+static inline void loop_sleep(unsigned long loops)
-static unsigned long long __thread nr_writes;
-static unsigned long long __thread nr_reads;
+static DEFINE_URCU_TLS(unsigned long long, nr_writes);
+static DEFINE_URCU_TLS(unsigned long long, nr_reads);
printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
"reader", pthread_self(), (unsigned long)gettid());
return ((void*)1);
printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
"reader", pthread_self(), (unsigned long)gettid());
return ((void*)1);
for (tidx = (long)nr_readers - 1; tidx >= 0; tidx--) {
pthread_mutex_unlock(&per_thread_lock[tidx].lock);
}
for (tidx = (long)nr_readers - 1; tidx >= 0; tidx--) {
pthread_mutex_unlock(&per_thread_lock[tidx].lock);
}
loop_sleep(wdelay);
}
printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
"writer", pthread_self(), (unsigned long)gettid());
loop_sleep(wdelay);
}
printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
"writer", pthread_self(), (unsigned long)gettid());
#endif
printf(" [-d delay] (writer period (us))");
printf(" [-c duration] (reader C.S. duration (in loops))");
#endif
printf(" [-d delay] (writer period (us))");
printf(" [-c duration] (reader C.S. duration (in loops))");
tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
tid_reader = malloc(sizeof(*tid_reader) * nr_readers);
tid_writer = malloc(sizeof(*tid_writer) * nr_writers);
tot_nr_reads = malloc(sizeof(*tot_nr_reads) * nr_readers);
tot_nr_writes = malloc(sizeof(*tot_nr_writes) * nr_writers);
per_thread_lock = malloc(sizeof(*per_thread_lock) * nr_readers);
tot_nr_reads = malloc(sizeof(*tot_nr_reads) * nr_readers);
tot_nr_writes = malloc(sizeof(*tot_nr_writes) * nr_writers);
per_thread_lock = malloc(sizeof(*per_thread_lock) * nr_readers);
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
tot_writes);
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
tot_writes);
- argv[0], duration, nr_readers, rduration,
+ argv[0], duration, nr_readers, rduration, wduration,
nr_writers, wdelay, tot_reads, tot_writes,
tot_reads + tot_writes);
free(tid_reader);
free(tid_writer);
nr_writers, wdelay, tot_reads, tot_writes,
tot_reads + tot_writes);
free(tid_reader);
free(tid_writer);