1 // RUN: %clangxx_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s
4 // bench.h needs pthread barriers which are not available on OS X
10 pthread_mutex_t mtx
[kMutex
];
12 void thread(int tid
) {
13 for (int i
= 0; i
< bench_niter
; i
++) {
14 int idx
= (i
% kMutex
);
16 idx
= kMutex
- idx
- 1;
17 pthread_mutex_lock(&mtx
[idx
]);
18 pthread_mutex_unlock(&mtx
[idx
]);
23 for (int i
= 0; i
< kMutex
; i
++)
24 pthread_mutex_init(&mtx
[i
], 0);
25 start_thread_group(2, thread
);