AM_CPPFLAGS="-include config.h"
AC_SUBST(AM_CPPFLAGS)
-AM_CFLAGS="-Wall -Wextra -Wno-unused-parameter -Wno-sign-compare $AM_CFLAGS"
+AM_CFLAGS="-Wall -Wextra -Wno-unused-parameter $AM_CFLAGS"
AC_SUBST(AM_CFLAGS)
AC_CONFIG_LINKS([
{
struct mynode *node =
caa_container_of(ht_node, struct mynode, node);
- const unsigned int *key = _key;
+ const int *key = _key;
return *key == node->value;
}
{
struct mynode *node =
caa_container_of(ht_node, struct mynode, node);
- const unsigned int *key = _key;
+ const int *key = _key;
return *key == node->value;
}
{
struct mynode *node =
caa_container_of(ht_node, struct mynode, node);
- const unsigned int *key = _key;
+ const int *key = _key;
return *key == node->value;
}
{
struct mynode *node =
caa_container_of(ht_node, struct mynode, node);
- const unsigned int *key = _key;
+ const int *key = _key;
return *key == node->value;
}
{
struct mynode *node =
caa_container_of(ht_node, struct mynode, node);
- const unsigned int *key = _key;
+ const int *key = _key;
return *key == node->value;
}
#include <signal.h>
#include "workqueue.h"
#include "urcu-die.h"
+#include "urcu-utils.h"
/*
* Split-counters lazily update the global counter each 1024
static
void ht_count_add(struct cds_lfht *ht, unsigned long size, unsigned long hash)
{
- unsigned long split_count;
+ unsigned long split_count, count;
int index;
- long count;
if (caa_unlikely(!ht->split_count))
return;
if ((count >> CHAIN_LEN_RESIZE_THRESHOLD) < size)
return;
- dbg_printf("add set global %ld\n", count);
+ dbg_printf("add set global %lu\n", count);
cds_lfht_resize_lazy_count(ht, size,
count >> (CHAIN_LEN_TARGET - 1));
}
static
void ht_count_del(struct cds_lfht *ht, unsigned long size, unsigned long hash)
{
- unsigned long split_count;
+ unsigned long split_count, count;
int index;
- long count;
if (caa_unlikely(!ht->split_count))
return;
{
unsigned long partition_len, start = 0;
struct partition_resize_work *work;
- int thread, ret;
- unsigned long nr_threads;
+ int ret;
+ unsigned long thread, nr_threads;
assert(nr_cpus_mask != -1);
if (nr_cpus_mask < 0 || len < 2 * MIN_PARTITION_PER_THREAD)
* partition size, up to the number of CPUs in the system.
*/
if (nr_cpus_mask > 0) {
- nr_threads = min(nr_cpus_mask + 1,
+ nr_threads = min_t(unsigned long, nr_cpus_mask + 1,
len >> MIN_PARTITION_PER_THREAD_ORDER);
} else {
nr_threads = 1;
void fini_table(struct cds_lfht *ht,
unsigned long first_order, unsigned long last_order)
{
- long i;
- unsigned long free_by_rcu_order = 0;
+ unsigned long free_by_rcu_order = 0, i;
dbg_printf("fini table: first_order %lu last_order %lu\n",
first_order, last_order);
}
}
+/*
+ * Never called with size < 1.
+ */
static
void cds_lfht_create_bucket(struct cds_lfht *ht, unsigned long size)
{
struct cds_lfht_node *prev, *node;
unsigned long order, len, i;
+ int bucket_order;
cds_lfht_alloc_bucket_table(ht, 0);
node->next = flag_bucket(get_end());
node->reverse_hash = 0;
- for (order = 1; order < cds_lfht_get_count_order_ulong(size) + 1; order++) {
+ bucket_order = cds_lfht_get_count_order_ulong(size);
+ assert(bucket_order >= 0);
+
+ for (order = 1; order < (unsigned long) bucket_order + 1; order++) {
len = 1UL << (order - 1);
cds_lfht_alloc_bucket_table(ht, order);
#define urcu_stringify(a) _urcu_stringify(a)
#define _urcu_stringify(a) #a
+#define max_t(type, x, y) \
+ ({ \
+ type __max1 = (x); \
+ type __max2 = (y); \
+ __max1 > __max2 ? __max1: __max2; \
+ })
+
+#define min_t(type, x, y) \
+ ({ \
+ type __min1 = (x); \
+ type __min2 = (y); \
+ __min1 <= __min2 ? __min1: __min2; \
+ })
+
/* There is no concept of symbol aliases on MacOS */
#ifdef __APPLE__
#define URCU_ATTR_ALIAS(x)
unsigned long long *count_reader, *count_writer;
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);
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,
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,
void *thr_reader(void *arg)
{
- int i, j;
+ unsigned int i, j;
caa_cycles_t time1, time2;
long tidx = (long)arg;
void *thr_writer(void *arg)
{
- int i, j;
+ unsigned int i, j;
long tidx;
caa_cycles_t time1, time2;
unsigned long long *count_reader, *count_writer;
unsigned long long tot_reads = 0, tot_writes = 0;
int i, a;
+ unsigned int i_thr;
if (argc < 4) {
show_usage(argc, argv);
next_aff = 0;
- for (i = 0; i < nr_readers; i++) {
- err = pthread_create(&tid_reader[i], NULL, thr_reader,
- &count_reader[i]);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+ &count_reader[i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_writers; i++) {
- err = pthread_create(&tid_writer[i], NULL, thr_writer,
- &count_writer[i]);
+ for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+ err = pthread_create(&tid_writer[i_thr], NULL, thr_writer,
+ &count_writer[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 += count_reader[i];
+ tot_reads += count_reader[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 += count_writer[i];
+ tot_writes += count_writer[i_thr];
}
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
void *thr_reader(void *arg)
{
- int i, j, ret;
+ unsigned int i, j;
+ int ret;
caa_cycles_t time1, time2;
printf("thread_begin %s, tid %lu\n",
void *thr_writer(void *arg)
{
- int i, j, ret;
+ unsigned int i, j;
+ int ret;
caa_cycles_t time1, time2;
printf("thread_begin %s, tid %lu\n",
unsigned long long *count_reader, *count_writer;
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);
next_aff = 0;
- for (i = 0; i < nr_readers; i++) {
- err = pthread_create(&tid_reader[i], NULL, thr_reader,
- &count_reader[i]);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+ &count_reader[i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_writers; i++) {
- err = pthread_create(&tid_writer[i], NULL, thr_writer,
- &count_writer[i]);
+ for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+ err = pthread_create(&tid_writer[i_thr], NULL, thr_writer,
+ &count_writer[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 += count_reader[i];
+ tot_reads += count_reader[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 += count_writer[i];
+ tot_writes += count_writer[i_thr];
}
-
+
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
tot_writes);
printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu "
* both alloc and free, which insures we never run over our tail.
*/
#define ARRAY_SIZE (1048576 * nr_writers)
-#define ARRAY_POISON 0xDEADBEEF
-static int array_index;
+#define ARRAY_POISON (int) 0xDEADBEEF
+static unsigned int array_index;
static struct test_array *test_array;
static struct test_array *test_array_alloc(void)
unsigned long long *count_reader, *count_writer;
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);
next_aff = 0;
- for (i = 0; i < nr_readers; i++) {
- err = pthread_create(&tid_reader[i], NULL, thr_reader,
- &count_reader[i]);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+ &count_reader[i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_writers; i++) {
- err = pthread_create(&tid_writer[i], NULL, thr_writer,
- &count_writer[i]);
+ for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+ err = pthread_create(&tid_writer[i_thr], NULL, thr_writer,
+ &count_writer[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 += count_reader[i];
+ tot_reads += count_reader[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 += count_writer[i];
+ tot_writes += count_writer[i_thr];
}
-
+
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
tot_writes);
printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu "
argv[0], duration, nr_readers, rduration, wduration,
nr_writers, wdelay, tot_reads, tot_writes,
tot_reads + tot_writes);
+
test_array_free(test_rcu_pointer);
free(test_array);
free(tid_reader);
free(tid_writer);
free(count_reader);
free(count_writer);
+
return 0;
}
unsigned long long *count_reader, *count_writer;
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);
next_aff = 0;
- for (i = 0; i < nr_readers; i++) {
- err = pthread_create(&tid_reader[i], NULL, thr_reader,
- &count_reader[i]);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+ &count_reader[i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_writers; i++) {
- err = pthread_create(&tid_writer[i], NULL, thr_writer,
- &count_writer[i]);
+ for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+ err = pthread_create(&tid_writer[i_thr], NULL, thr_writer,
+ &count_writer[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 += count_reader[i];
+ tot_reads += count_reader[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 += count_writer[i];
+ tot_writes += count_writer[i_thr];
}
-
+
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
tot_writes);
printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu "
argv[0], duration, nr_readers, rduration, wduration,
nr_writers, wdelay, tot_reads, tot_writes,
tot_reads + tot_writes);
+
free(test_rcu_pointer);
free(tid_reader);
free(tid_writer);
free(count_reader);
free(count_writer);
+
return 0;
}
unsigned long long *count_reader;
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);
next_aff = 0;
- for (i = 0; i < nr_readers; i++) {
- err = pthread_create(&tid_reader[i], NULL, thr_reader,
- &count_reader[i]);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+ &count_reader[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 += count_reader[i];
+ tot_reads += count_reader[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,
tot_writes);
printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu "
unsigned long long *count_reader;
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);
count_reader = calloc(nr_readers, sizeof(*count_reader));
tot_nr_writes = calloc(nr_writers, sizeof(*tot_nr_writes));
pending_reclaims = calloc(nr_writers, sizeof(*pending_reclaims));
- if (reclaim_batch * sizeof(*pending_reclaims[i].queue)
+
+ if (reclaim_batch * sizeof(*pending_reclaims[0].queue)
< CAA_CACHE_LINE_SIZE)
- for (i = 0; i < nr_writers; i++)
- pending_reclaims[i].queue = calloc(1, CAA_CACHE_LINE_SIZE);
+ for (i_thr = 0; i_thr < nr_writers; i_thr++)
+ pending_reclaims[i_thr].queue = calloc(1, CAA_CACHE_LINE_SIZE);
else
- for (i = 0; i < nr_writers; i++)
- pending_reclaims[i].queue = calloc(reclaim_batch,
- sizeof(*pending_reclaims[i].queue));
- for (i = 0; i < nr_writers; i++)
- pending_reclaims[i].head = pending_reclaims[i].queue;
+ for (i_thr = 0; i_thr < nr_writers; i_thr++)
+ pending_reclaims[i_thr].queue = calloc(reclaim_batch,
+ sizeof(*pending_reclaims[i_thr].queue));
+ for (i_thr = 0; i_thr < nr_writers; i_thr++)
+ pending_reclaims[i_thr].head = pending_reclaims[i_thr].queue;
next_aff = 0;
- for (i = 0; i < nr_readers; i++) {
- err = pthread_create(&tid_reader[i], NULL, thr_reader,
- &count_reader[i]);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+ &count_reader[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 += count_reader[i];
+ tot_reads += count_reader[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];
- rcu_gc_clear_queue(i);
+ tot_writes += tot_nr_writes[i_thr];
+ rcu_gc_clear_queue(i_thr);
}
-
+
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
tot_writes);
printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu "
argv[0], duration, nr_readers, rduration, wduration,
nr_writers, wdelay, tot_reads, tot_writes,
tot_reads + tot_writes, reclaim_batch);
+
free(tid_reader);
free(tid_writer);
free(count_reader);
free(tot_nr_writes);
- for (i = 0; i < nr_writers; i++)
- free(pending_reclaims[i].queue);
+
+ for (i_thr = 0; i_thr < nr_writers; i_thr++)
+ free(pending_reclaims[i_thr].queue);
free(pending_reclaims);
return 0;
unsigned long count;
long approx_before, approx_after;
int i, a, ret, err, mainret = 0;
+ unsigned int i_thr;
struct sigaction act;
unsigned int remain;
unsigned int nr_readers_created = 0, nr_writers_created = 0;
mainret = 1;
goto end;
}
-
+
err = sscanf(argv[3], "%lu", &duration);
if (err != 1) {
show_usage(argc, argv);
goto end_close_pipe;
}
- for (i = 0; i < nr_readers; i++) {
- err = pthread_create(&tid_reader[i],
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_create(&tid_reader[i_thr],
NULL, get_thr_reader_cb(),
- &count_reader[i]);
+ &count_reader[i_thr]);
if (err != 0) {
errno = err;
mainret = 1;
}
nr_readers_created++;
}
- for (i = 0; i < nr_writers; i++) {
- err = pthread_create(&tid_writer[i],
+ for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+ err = pthread_create(&tid_writer[i_thr],
NULL, get_thr_writer_cb(),
- &count_writer[i]);
+ &count_writer[i_thr]);
if (err != 0) {
errno = err;
mainret = 1;
test_stop = 1;
end_pthread_join:
- for (i = 0; i < nr_readers_created; i++) {
- err = pthread_join(tid_reader[i], &tret);
+ for (i_thr = 0; i_thr < nr_readers_created; i_thr++) {
+ err = pthread_join(tid_reader[i_thr], &tret);
if (err != 0) {
errno = err;
mainret = 1;
perror("pthread_join");
}
- tot_reads += count_reader[i];
+ tot_reads += count_reader[i_thr];
}
- for (i = 0; i < nr_writers_created; i++) {
- err = pthread_join(tid_writer[i], &tret);
+ for (i_thr = 0; i_thr < nr_writers_created; i_thr++) {
+ err = pthread_join(tid_writer[i_thr], &tret);
if (err != 0) {
errno = err;
mainret = 1;
perror("pthread_join");
}
- tot_writes += count_writer[i].update_ops;
- tot_add += count_writer[i].add;
- tot_add_exist += count_writer[i].add_exist;
- tot_remove += count_writer[i].remove;
+ tot_writes += count_writer[i_thr].update_ops;
+ tot_add += count_writer[i_thr].add;
+ tot_add_exist += count_writer[i_thr].add_exist;
+ tot_remove += count_writer[i_thr].remove;
}
/* teardown counter thread */
tot_successful_dequeues = 0;
unsigned long long end_dequeues = 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);
next_aff = 0;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_create(&tid_enqueuer[i], NULL, thr_enqueuer,
- &count_enqueuer[2 * i]);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_create(&tid_enqueuer[i_thr], NULL, thr_enqueuer,
+ &count_enqueuer[2 * i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_create(&tid_dequeuer[i], NULL, thr_dequeuer,
- &count_dequeuer[2 * i]);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer,
+ &count_dequeuer[2 * i_thr]);
if (err != 0)
exit(1);
}
test_go = 1;
- for (i = 0; i < duration; i++) {
+ for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
if (verbose_mode) {
fwrite(".", sizeof(char), 1, stdout);
test_stop = 1;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_join(tid_enqueuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_join(tid_enqueuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_enqueues += count_enqueuer[2 * i];
- tot_successful_enqueues += count_enqueuer[2 * i + 1];
+ tot_enqueues += count_enqueuer[2 * i_thr];
+ tot_successful_enqueues += count_enqueuer[2 * i_thr + 1];
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_join(tid_dequeuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_join(tid_dequeuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_dequeues += count_dequeuer[2 * i];
- tot_successful_dequeues += count_dequeuer[2 * i + 1];
+ tot_dequeues += count_dequeuer[2 * i_thr];
+ tot_successful_dequeues += count_dequeuer[2 * i_thr + 1];
}
-
+
test_end(&q, &end_dequeues);
err = cds_lfq_destroy_rcu(&q);
assert(!err);
free(count_dequeuer);
free(tid_enqueuer);
free(tid_dequeuer);
+
return 0;
}
tot_successful_dequeues = 0;
unsigned long long end_dequeues = 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);
next_aff = 0;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_create(&tid_enqueuer[i], NULL, thr_enqueuer,
- &count_enqueuer[2 * i]);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_create(&tid_enqueuer[i_thr], NULL, thr_enqueuer,
+ &count_enqueuer[2 * i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_create(&tid_dequeuer[i], NULL, thr_dequeuer,
- &count_dequeuer[2 * i]);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer,
+ &count_dequeuer[2 * i_thr]);
if (err != 0)
exit(1);
}
test_go = 1;
- for (i = 0; i < duration; i++) {
+ for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
if (verbose_mode) {
fwrite(".", sizeof(char), 1, stdout);
test_stop = 1;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_join(tid_enqueuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_join(tid_enqueuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_enqueues += count_enqueuer[2 * i];
- tot_successful_enqueues += count_enqueuer[2 * i + 1];
+ tot_enqueues += count_enqueuer[2 * i_thr];
+ tot_successful_enqueues += count_enqueuer[2 * i_thr + 1];
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_join(tid_dequeuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_join(tid_dequeuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_dequeues += count_dequeuer[2 * i];
- tot_successful_dequeues += count_dequeuer[2 * i + 1];
+ tot_dequeues += count_dequeuer[2 * i_thr];
+ tot_successful_dequeues += count_dequeuer[2 * i_thr + 1];
}
-
+
test_end(&s, &end_dequeues);
printf_verbose("total number of enqueues : %llu, dequeues %llu\n",
free(count_dequeuer);
free(tid_enqueuer);
free(tid_dequeuer);
+
return 0;
}
tot_successful_dequeues = 0;
unsigned long long end_dequeues = 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);
next_aff = 0;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_create(&tid_enqueuer[i], NULL, thr_enqueuer,
- &count_enqueuer[2 * i]);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_create(&tid_enqueuer[i_thr], NULL, thr_enqueuer,
+ &count_enqueuer[2 * i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_create(&tid_dequeuer[i], NULL, thr_dequeuer,
- &count_dequeuer[2 * i]);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer,
+ &count_dequeuer[2 * i_thr]);
if (err != 0)
exit(1);
}
test_go = 1;
- for (i = 0; i < duration; i++) {
+ for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
if (verbose_mode) {
fwrite(".", sizeof(char), 1, stdout);
test_stop = 1;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_join(tid_enqueuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_join(tid_enqueuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_enqueues += count_enqueuer[2 * i];
- tot_successful_enqueues += count_enqueuer[2 * i + 1];
+ tot_enqueues += count_enqueuer[2 * i_thr];
+ tot_successful_enqueues += count_enqueuer[2 * i_thr + 1];
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_join(tid_dequeuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_join(tid_dequeuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_dequeues += count_dequeuer[2 * i];
- tot_successful_dequeues += count_dequeuer[2 * i + 1];
+ tot_dequeues += count_dequeuer[2 * i_thr];
+ tot_successful_dequeues += count_dequeuer[2 * i_thr + 1];
}
-
+
test_end(&s, &end_dequeues);
printf_verbose("total number of enqueues : %llu, dequeues %llu\n",
unsigned long long *count_reader, *count_writer;
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);
next_aff = 0;
- for (i = 0; i < nr_readers; i++) {
- err = pthread_create(&tid_reader[i], NULL, thr_reader,
- &count_reader[i]);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+ &count_reader[i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_writers; i++) {
- err = pthread_create(&tid_writer[i], NULL, thr_writer,
- &count_writer[i]);
+ for (i_thr = 0; i_thr < nr_writers; i_thr++) {
+ err = pthread_create(&tid_writer[i_thr], NULL, thr_writer,
+ &count_writer[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 += count_reader[i];
+ tot_reads += count_reader[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 += count_writer[i];
+ tot_writes += count_writer[i_thr];
}
-
+
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
tot_writes);
printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu "
unsigned long long *count_reader;
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);
count_reader = calloc(nr_readers, sizeof(*count_reader));
tot_nr_writes = calloc(nr_writers, sizeof(*tot_nr_writes));
pending_reclaims = calloc(nr_writers, sizeof(*pending_reclaims));
- if (reclaim_batch * sizeof(*pending_reclaims[i].queue)
+ if (reclaim_batch * sizeof(*pending_reclaims[0].queue)
< CAA_CACHE_LINE_SIZE)
- for (i = 0; i < nr_writers; i++)
- pending_reclaims[i].queue = calloc(1, CAA_CACHE_LINE_SIZE);
+ for (i_thr = 0; i_thr < nr_writers; i_thr++)
+ pending_reclaims[i_thr].queue = calloc(1, CAA_CACHE_LINE_SIZE);
else
- for (i = 0; i < nr_writers; i++)
- pending_reclaims[i].queue = calloc(reclaim_batch,
- sizeof(*pending_reclaims[i].queue));
- for (i = 0; i < nr_writers; i++)
- pending_reclaims[i].head = pending_reclaims[i].queue;
+ for (i_thr = 0; i_thr < nr_writers; i_thr++)
+ pending_reclaims[i_thr].queue = calloc(reclaim_batch,
+ sizeof(*pending_reclaims[i_thr].queue));
+ for (i_thr = 0; i_thr < nr_writers; i_thr++)
+ pending_reclaims[i_thr].head = pending_reclaims[i_thr].queue;
next_aff = 0;
- for (i = 0; i < nr_readers; i++) {
- err = pthread_create(&tid_reader[i], NULL, thr_reader,
- &count_reader[i]);
+ for (i_thr = 0; i_thr < nr_readers; i_thr++) {
+ err = pthread_create(&tid_reader[i_thr], NULL, thr_reader,
+ &count_reader[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 += count_reader[i];
+ tot_reads += count_reader[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];
- rcu_gc_clear_queue(i);
+ tot_writes += tot_nr_writes[i_thr];
+ rcu_gc_clear_queue(i_thr);
}
-
+
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
tot_writes);
printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu wdur %6lu "
argv[0], duration, nr_readers, rduration, wduration,
nr_writers, wdelay, tot_reads, tot_writes,
tot_reads + tot_writes, reclaim_batch);
+
free(tid_reader);
free(tid_writer);
free(count_reader);
free(tot_nr_writes);
- for (i = 0; i < nr_writers; i++)
- free(pending_reclaims[i].queue);
+
+ for (i_thr = 0; i_thr < nr_writers; i_thr++)
+ free(pending_reclaims[i_thr].queue);
free(pending_reclaims);
return 0;
void *thr_reader(void *arg)
{
- int i, j;
+ unsigned int i, j;
struct test_array *local_ptr;
caa_cycles_t time1, time2;
void *thr_writer(void *arg)
{
- int i, j;
+ unsigned int i, j;
struct test_array *new, *old;
caa_cycles_t time1, time2;
void *thr_reader(void *arg)
{
- int i, j;
+ unsigned int i, j;
struct test_array *local_ptr;
caa_cycles_t time1, time2;
void *thr_writer(void *arg)
{
- int i, j;
+ unsigned int i, j;
struct test_array *new, *old;
caa_cycles_t time1, time2;
static int verbose_mode;
static int test_dequeue, test_splice, test_wait_empty;
-static int test_enqueue_stopped;
+static unsigned int test_enqueue_stopped;
#define printf_verbose(fmt, args...) \
do { \
tot_splice = 0, tot_dequeue_last = 0;
unsigned long long end_dequeues = 0;
int i, a, retval = 0;
+ 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);
next_aff = 0;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_create(&tid_enqueuer[i], NULL, thr_enqueuer,
- &count_enqueuer[3 * i]);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_create(&tid_enqueuer[i_thr], NULL, thr_enqueuer,
+ &count_enqueuer[3 * i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_create(&tid_dequeuer[i], NULL, thr_dequeuer,
- &count_dequeuer[4 * i]);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer,
+ &count_dequeuer[4 * i_thr]);
if (err != 0)
exit(1);
}
test_go = 1;
- for (i = 0; i < duration; i++) {
+ for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
if (verbose_mode) {
fwrite(".", sizeof(char), 1, stdout);
test_stop_dequeue = 1;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_join(tid_enqueuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_join(tid_enqueuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_enqueues += count_enqueuer[3 * i];
- tot_successful_enqueues += count_enqueuer[3 * i + 1];
- tot_empty_dest_enqueues += count_enqueuer[3 * i + 2];
+ tot_enqueues += count_enqueuer[3 * i_thr];
+ tot_successful_enqueues += count_enqueuer[3 * i_thr + 1];
+ tot_empty_dest_enqueues += count_enqueuer[3 * i_thr + 2];
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_join(tid_dequeuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_join(tid_dequeuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_dequeues += count_dequeuer[4 * i];
- tot_successful_dequeues += count_dequeuer[4 * i + 1];
- tot_splice += count_dequeuer[4 * i + 2];
- tot_dequeue_last += count_dequeuer[4 * i + 3];
+ tot_dequeues += count_dequeuer[4 * i_thr];
+ tot_successful_dequeues += count_dequeuer[4 * i_thr + 1];
+ tot_splice += count_dequeuer[4 * i_thr + 2];
+ tot_dequeue_last += count_dequeuer[4 * i_thr + 3];
}
-
+
test_end(&end_dequeues, &tot_dequeue_last);
printf_verbose("total number of enqueues : %llu, dequeues %llu\n",
free(count_dequeuer);
free(tid_enqueuer);
free(tid_dequeuer);
+
return retval;
}
tot_successful_dequeues = 0;
unsigned long long end_dequeues = 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);
next_aff = 0;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_create(&tid_enqueuer[i], NULL, thr_enqueuer,
- &count_enqueuer[2 * i]);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_create(&tid_enqueuer[i_thr], NULL, thr_enqueuer,
+ &count_enqueuer[2 * i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_create(&tid_dequeuer[i], NULL, thr_dequeuer,
- &count_dequeuer[2 * i]);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer,
+ &count_dequeuer[2 * i_thr]);
if (err != 0)
exit(1);
}
test_go = 1;
- for (i = 0; i < duration; i++) {
+ for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
if (verbose_mode) {
fwrite(".", sizeof(char), 1, stdout);
test_stop = 1;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_join(tid_enqueuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_join(tid_enqueuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_enqueues += count_enqueuer[2 * i];
- tot_successful_enqueues += count_enqueuer[2 * i + 1];
+ tot_enqueues += count_enqueuer[2 * i_thr];
+ tot_successful_enqueues += count_enqueuer[2 * i_thr + 1];
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_join(tid_dequeuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_join(tid_dequeuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_dequeues += count_dequeuer[2 * i];
- tot_successful_dequeues += count_dequeuer[2 * i + 1];
+ tot_dequeues += count_dequeuer[2 * i_thr];
+ tot_successful_dequeues += count_dequeuer[2 * i_thr + 1];
}
-
+
test_end(&q, &end_dequeues);
printf_verbose("total number of enqueues : %llu, dequeues %llu\n",
free(count_dequeuer);
free(tid_enqueuer);
free(tid_dequeuer);
+
return 0;
}
static int verbose_mode;
static int test_pop, test_pop_all, test_wait_empty;
-static int test_enqueue_stopped;
+static unsigned int test_enqueue_stopped;
#define printf_verbose(fmt, args...) \
do { \
tot_pop_all = 0, tot_pop_last = 0;
unsigned long long end_dequeues = 0;
int i, a, retval = 0;
+ 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);
next_aff = 0;
- for (i = 0; i < nr_enqueuers; i++) {
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
err = pthread_create(&tid_enqueuer[i], NULL, thr_enqueuer,
- &count_enqueuer[3 * i]);
+ &count_enqueuer[3 * i_thr]);
if (err != 0)
exit(1);
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_create(&tid_dequeuer[i], NULL, thr_dequeuer,
- &count_dequeuer[4 * i]);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_create(&tid_dequeuer[i_thr], NULL, thr_dequeuer,
+ &count_dequeuer[4 * i_thr]);
if (err != 0)
exit(1);
}
test_go = 1;
- for (i = 0; i < duration; i++) {
+ for (i_thr = 0; i_thr < duration; i_thr++) {
sleep(1);
if (verbose_mode) {
fwrite(".", sizeof(char), 1, stdout);
test_stop_dequeue = 1;
- for (i = 0; i < nr_enqueuers; i++) {
- err = pthread_join(tid_enqueuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_enqueuers; i_thr++) {
+ err = pthread_join(tid_enqueuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_enqueues += count_enqueuer[3 * i];
- tot_successful_enqueues += count_enqueuer[3 * i + 1];
- tot_empty_dest_enqueues += count_enqueuer[3 * i + 2];
+ tot_enqueues += count_enqueuer[3 * i_thr];
+ tot_successful_enqueues += count_enqueuer[3 * i_thr + 1];
+ tot_empty_dest_enqueues += count_enqueuer[3 * i_thr + 2];
}
- for (i = 0; i < nr_dequeuers; i++) {
- err = pthread_join(tid_dequeuer[i], &tret);
+ for (i_thr = 0; i_thr < nr_dequeuers; i_thr++) {
+ err = pthread_join(tid_dequeuer[i_thr], &tret);
if (err != 0)
exit(1);
- tot_dequeues += count_dequeuer[4 * i];
- tot_successful_dequeues += count_dequeuer[4 * i + 1];
- tot_pop_all += count_dequeuer[4 * i + 2];
- tot_pop_last += count_dequeuer[4 * i + 3];
+ tot_dequeues += count_dequeuer[4 * i_thr];
+ tot_successful_dequeues += count_dequeuer[4 * i_thr + 1];
+ tot_pop_all += count_dequeuer[4 * i_thr + 2];
+ tot_pop_last += count_dequeuer[4 * i_thr + 3];
}
-
+
test_end(&s, &end_dequeues, &tot_pop_last);
printf_verbose("total number of enqueues : %llu, dequeues %llu\n",
tot_pop_last);
retval = 1;
}
+
cds_wfs_destroy(&s);
free(count_enqueuer);
free(count_dequeuer);
free(tid_enqueuer);
free(tid_dequeuer);
+
return retval;
}