• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include "test.h"
3 
4 pthread_barrier_t B;
5 int Global;
6 
Thread1(void * x)7 void *Thread1(void *x) {
8   pthread_barrier_init(&B, 0, 2);
9   barrier_wait(&barrier);
10   pthread_barrier_wait(&B);
11   return NULL;
12 }
13 
Thread2(void * x)14 void *Thread2(void *x) {
15   barrier_wait(&barrier);
16   pthread_barrier_wait(&B);
17   return NULL;
18 }
19 
main()20 int main() {
21   barrier_init(&barrier, 2);
22   pthread_t t;
23   pthread_create(&t, NULL, Thread1, NULL);
24   Thread2(0);
25   pthread_join(t, NULL);
26   pthread_barrier_destroy(&B);
27   return 0;
28 }
29 
30 // CHECK:      WARNING: ThreadSanitizer: data race
31