diff options
Diffstat (limited to 'test/tsan/mutexset3.cc')
-rw-r--r-- | test/tsan/mutexset3.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/tsan/mutexset3.cc b/test/tsan/mutexset3.cc index e14bb1111e32..ce64cf86e37c 100644 --- a/test/tsan/mutexset3.cc +++ b/test/tsan/mutexset3.cc @@ -1,14 +1,12 @@ // 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; pthread_mutex_t mtx2; void *Thread1(void *x) { - sleep(1); + barrier_wait(&barrier); pthread_mutex_lock(&mtx1); pthread_mutex_lock(&mtx2); Global++; @@ -19,10 +17,12 @@ void *Thread1(void *x) { void *Thread2(void *x) { Global--; + 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]+]], write [[M2:M[0-9]+]]): |