summaryrefslogtreecommitdiff
path: root/test/tsan/mutexset6.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsan/mutexset6.cc')
-rw-r--r--test/tsan/mutexset6.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/tsan/mutexset6.cc b/test/tsan/mutexset6.cc
index 07dcc0a73..f4251db69 100644
--- a/test/tsan/mutexset6.cc
+++ b/test/tsan/mutexset6.cc
@@ -1,7 +1,5 @@
// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
+#include "test.h"
int Global;
pthread_mutex_t mtx1;
@@ -9,7 +7,7 @@ pthread_spinlock_t mtx2;
pthread_rwlock_t mtx3;
void *Thread1(void *x) {
- sleep(1);
+ barrier_wait(&barrier);
pthread_mutex_lock(&mtx1);
Global++;
pthread_mutex_unlock(&mtx1);
@@ -24,10 +22,12 @@ void *Thread2(void *x) {
Global--;
pthread_spin_unlock(&mtx2);
pthread_rwlock_unlock(&mtx3);
+ barrier_wait(&barrier);
return NULL;
}
int main() {
+ barrier_init(&barrier, 2);
// CHECK: WARNING: ThreadSanitizer: data race
// CHECK: Write of size 4 at {{.*}} by thread T1
// CHECK: (mutexes: write [[M1:M[0-9]+]]):