* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#define _GNU_SOURCE
-#include "config.h"
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
cmm_smp_mb();
for (;;) {
- for (tidx = 0; tidx < nr_readers; tidx++) {
+ for (tidx = 0; tidx < (long)nr_readers; tidx++) {
urcu_mutex_lock(&per_thread_lock[tidx].lock);
}
test_array.a = 0;
void *tret;
unsigned long long tot_reads = 0, tot_writes = 0;
int i, a;
+ unsigned int i_thr;
if (argc < 4) {
show_usage(argc, argv);
show_usage(argc, argv);
return -1;
}
-
+
err = sscanf(argv[3], "%lu", &duration);
if (err != 1) {
show_usage(argc, argv);
tot_nr_reads = calloc(nr_readers, sizeof(*tot_nr_reads));
tot_nr_writes = calloc(nr_writers, sizeof(*tot_nr_writes));
per_thread_lock = calloc(nr_readers, sizeof(*per_thread_lock));
- for (i = 0; i < nr_readers; i++) {
- pthread_mutex_init(&per_thread_lock[i].lock, NULL);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ pthread_mutex_init(&per_thread_lock[i_thr].lock, NULL);
}
next_aff = 0;
- for (i = 0; i < nr_readers; i++) {
- err = pthread_create(&tid_reader[i], NULL, thr_reader,
- (void *)(long)i);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+ (void *)(long)i_thr);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_writers; i++) {
- err = pthread_create(&tid_writer[i], NULL, thr_writer,
- (void *)(long)i);
+ for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+ err = pthread_create(&tid_writer[i_thr], NULL, thr_writer,
+ (void *)(long)i_thr);
if (err != 0)
exit(1);
}
test_stop = 1;
- for (i = 0; i < nr_readers; i++) {
- err = pthread_join(tid_reader[i], &tret);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_join(tid_reader[i_thr], &tret);
if (err != 0)
exit(1);
- tot_reads += tot_nr_reads[i];
+ tot_reads += tot_nr_reads[i_thr];
}
- for (i = 0; i < nr_writers; i++) {
- err = pthread_join(tid_writer[i], &tret);
+ for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+ err = pthread_join(tid_writer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_writes += tot_nr_writes[i];
+ tot_writes += tot_nr_writes[i_thr];
}
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,