model: improve get_next_thread() comments
[c11tester.git] / test / rmwprog.c
index a74ae426ca95df7e90f63424d4aaaa3a327e7292..57ab54462bab9b03b48a87cf86578d06c8c5e070 100644 (file)
@@ -1,21 +1,27 @@
+#include <stdlib.h>
 #include <stdio.h>
+#include <threads.h>
+#include <stdatomic.h>
 
-#include "libthreads.h"
 #include "librace.h"
-#include "stdatomic.h"
 
 atomic_int x;
+static int N = 2;
 
 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;
 
+       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);