projects
/
model-checker.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Annotation Support
[model-checker.git]
/
test
/
rmwprog.c
diff --git
a/test/rmwprog.c
b/test/rmwprog.c
index 5911e5a3cdd870820a1af60509bbbfbc1dea0868..ebace1ec262966d5d367afefd5dbaaddef168a26 100644
(file)
--- a/
test/rmwprog.c
+++ b/
test/rmwprog.c
@@
-1,21
+1,28
@@
+#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
-
#include <threads.h>
#include <threads.h>
+#include <stdatomic.h>
+
#include "librace.h"
#include "librace.h"
-#include "
stdatomic
.h"
+#include "
model-assert
.h"
atomic_int x;
atomic_int x;
+static int N = 2;
static void a(void *obj)
{
static void a(void *obj)
{
- atomic_fetch_add_explicit(&x, 1, memory_order_relaxed);
- atomic_fetch_add_explicit(&x, 1, memory_order_relaxed);
+ int i;
+ for (i = 0; i < N; i++)
+ atomic_fetch_add_explicit(&x, 1, memory_order_relaxed);
}
int user_main(int argc, char **argv)
{
thrd_t t1, t2;
}
int user_main(int argc, char **argv)
{
thrd_t t1, t2;
+ if (argc > 1)
+ N = atoi(argv[1]);
+
atomic_init(&x, 0);
thrd_create(&t1, (thrd_start_t)&a, NULL);
thrd_create(&t2, (thrd_start_t)&a, NULL);
atomic_init(&x, 0);
thrd_create(&t1, (thrd_start_t)&a, NULL);
thrd_create(&t2, (thrd_start_t)&a, NULL);
@@
-23,5
+30,7
@@
int user_main(int argc, char **argv)
thrd_join(t1);
thrd_join(t2);
thrd_join(t1);
thrd_join(t2);
+ MODEL_ASSERT(atomic_load(&x) == N * 2);
+
return 0;
}
return 0;
}