projects
/
urcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleanup: enable signed/unsigned compare compiler warning
[urcu.git]
/
tests
/
benchmark
/
test_mutex.c
diff --git
a/tests/benchmark/test_mutex.c
b/tests/benchmark/test_mutex.c
index 919654daa063d6589ec3e51ed99a8a8bc2c30a97..19eb7c4f929b8cb84d5cea95040f4669a7bcd81f 100644
(file)
--- a/
tests/benchmark/test_mutex.c
+++ b/
tests/benchmark/test_mutex.c
@@
-20,8
+20,6
@@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
* 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>
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
@@
-43,8
+41,6
@@
#ifndef DYNAMIC_LINK_TEST
#define _LGPL_SOURCE
#ifndef DYNAMIC_LINK_TEST
#define _LGPL_SOURCE
-#else
-#define debug_yield_read()
#endif
#include <urcu.h>
#endif
#include <urcu.h>
@@
-181,8
+177,11
@@
void *thr_reader(void *data)
}
for (;;) {
}
for (;;) {
+ int v;
+
pthread_mutex_lock(&lock);
pthread_mutex_lock(&lock);
- assert(test_array.a == 8);
+ v = test_array.a;
+ assert(v == 8);
if (caa_unlikely(rduration))
loop_sleep(rduration);
pthread_mutex_unlock(&lock);
if (caa_unlikely(rduration))
loop_sleep(rduration);
pthread_mutex_unlock(&lock);
@@
-237,9
+236,6
@@
void show_usage(int argc, char **argv)
printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
argv[0]);
printf("OPTIONS:\n");
printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
argv[0]);
printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
- printf(" [-r] [-w] (yield reader and/or writer)\n");
-#endif
printf(" [-d delay] (writer period (us))\n");
printf(" [-c duration] (reader C.S. duration (in loops))\n");
printf(" [-e duration] (writer C.S. duration (in loops))\n");
printf(" [-d delay] (writer period (us))\n");
printf(" [-c duration] (reader C.S. duration (in loops))\n");
printf(" [-e duration] (writer C.S. duration (in loops))\n");
@@
-256,6
+252,7
@@
int main(int argc, char **argv)
unsigned long long *count_reader, *count_writer;
unsigned long long tot_reads = 0, tot_writes = 0;
int i, a;
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);
if (argc < 4) {
show_usage(argc, argv);
@@
-274,7
+271,7
@@
int main(int argc, char **argv)
show_usage(argc, argv);
return -1;
}
show_usage(argc, argv);
return -1;
}
-
+
err = sscanf(argv[3], "%lu", &duration);
if (err != 1) {
show_usage(argc, argv);
err = sscanf(argv[3], "%lu", &duration);
if (err != 1) {
show_usage(argc, argv);
@@
-285,14
+282,6
@@
int main(int argc, char **argv)
if (argv[i][0] != '-')
continue;
switch (argv[i][1]) {
if (argv[i][0] != '-')
continue;
switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
- case 'r':
- yield_active |= YIELD_READ;
- break;
- case 'w':
- yield_active |= YIELD_WRITE;
- break;
-#endif
case 'a':
if (argc < i + 2) {
show_usage(argc, argv);
case 'a':
if (argc < i + 2) {
show_usage(argc, argv);
@@
-346,15
+335,15
@@
int main(int argc, char **argv)
next_aff = 0;
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);
}
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);
}
if (err != 0)
exit(1);
}
@@
-367,17
+356,17
@@
int main(int argc, char **argv)
test_stop = 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);
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);
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,
}
printf_verbose("total number of reads : %llu, writes %llu\n", tot_reads,
This page took
0.024339 seconds
and
4
git commands to generate.