aboutsummaryrefslogtreecommitdiff
path: root/test/tsan/mutexset2.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/tsan/mutexset2.cc')
-rw-r--r--test/tsan/mutexset2.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/tsan/mutexset2.cc b/test/tsan/mutexset2.cc
index 01a5f5df6e94..2a3e5bb95e87 100644
--- a/test/tsan/mutexset2.cc
+++ b/test/tsan/mutexset2.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 mtx;
@@ -10,16 +8,18 @@ void *Thread1(void *x) {
pthread_mutex_lock(&mtx);
Global++;
pthread_mutex_unlock(&mtx);
+ barrier_wait(&barrier);
return NULL;
}
void *Thread2(void *x) {
- sleep(1);
+ barrier_wait(&barrier);
Global--;
return NULL;
}
int main() {
+ barrier_init(&barrier, 2);
// CHECK: WARNING: ThreadSanitizer: data race
// CHECK: Write of size 4 at {{.*}} by thread T2:
// CHECK: Previous write of size 4 at {{.*}} by thread T1