1 // RUN: %clangxx_tsan %s -o %t 2 // RUN: %run %t 2>&1 | FileCheck %s 3 4 #include "bench.h" 5 6 const int kMutex = 10; 7 pthread_mutex_t mtx[kMutex]; 8 9 void thread(int tid) { 10 for (int i = 0; i < bench_niter; i++) { 11 int idx = (i % kMutex); 12 if (tid == 0) 13 idx = kMutex - idx - 1; 14 pthread_mutex_lock(&mtx[idx]); 15 pthread_mutex_unlock(&mtx[idx]); 16 } 17 } 18 19 void bench() { 20 for (int i = 0; i < kMutex; i++) 21 pthread_mutex_init(&mtx[i], 0); 22 start_thread_group(2, thread); 23 } 24 25 // CHECK: DONE 26 27