From 24edf5ea28ecd116c1faa76ed41de1cfbf6d6d1e Mon Sep 17 00:00:00 2001
From: Brian Norris <banorris@uci.edu>
Date: Mon, 29 Oct 2012 11:44:52 -0700
Subject: [PATCH] tests: add thinair test

---
 test/thinair.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 test/thinair.c

diff --git a/test/thinair.c b/test/thinair.c
new file mode 100644
index 00000000..dcd7615f
--- /dev/null
+++ b/test/thinair.c
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <threads.h>
+#include <stdatomic.h>
+
+#include "librace.h"
+
+atomic_int x;
+atomic_int y;
+
+static void a(void *obj)
+{
+	int r1=atomic_load_explicit(&x, memory_order_relaxed);
+	atomic_store_explicit(&y, r1, memory_order_relaxed);
+	printf("r1=%d\n",r1);
+}
+
+static void b(void *obj)
+{
+	int r2=atomic_load_explicit(&y, memory_order_relaxed);
+	atomic_store_explicit(&x, r2, memory_order_relaxed);
+	atomic_store_explicit(&x, r2 + 1, memory_order_relaxed);
+	printf("r2=%d\n",r2);
+}
+
+int user_main(int argc, char **argv)
+{
+	thrd_t t1, t2;
+
+	atomic_init(&x, -1);
+	atomic_init(&y, 0);
+
+	printf("Thread %d: creating 2 threads\n", thrd_current());
+	thrd_create(&t1, (thrd_start_t)&a, NULL);
+	thrd_create(&t2, (thrd_start_t)&b, NULL);
+
+	thrd_join(t1);
+	thrd_join(t2);
+	printf("Thread %d is finished\n", thrd_current());
+
+	return 0;
+}
-- 
2.34.1