aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/bench_rwmutex.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsan/bench_rwmutex.cc')
-rw-r--r--test/tsan/bench_rwmutex.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/tsan/bench_rwmutex.cc b/test/tsan/bench_rwmutex.cc
new file mode 100644
index 000000000000..818ee8c82bc1
--- /dev/null
+++ b/test/tsan/bench_rwmutex.cc
@@ -0,0 +1,25 @@
+// RUN: %clangxx_tsan %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s
+
+#include "bench.h"
+
+pthread_rwlock_t mtx;
+
+void thread(int tid) {
+ for (int i = 0; i < bench_niter; i++) {
+ pthread_rwlock_rdlock(&mtx);
+ pthread_rwlock_unlock(&mtx);
+ }
+}
+
+void bench() {
+ pthread_rwlock_init(&mtx, 0);
+ pthread_rwlock_wrlock(&mtx);
+ pthread_rwlock_unlock(&mtx);
+ pthread_rwlock_rdlock(&mtx);
+ pthread_rwlock_unlock(&mtx);
+ start_thread_group(bench_nthread, thread);
+}
+
+// CHECK: DONE
+