blob: 0fa1db0c883c1d9e55092ce19467db1217009278 [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001// RUN: %clangxx_tsan %s -o %t
2// RUN: %run %t 2>&1 | FileCheck %s
3
4#include "bench.h"
5
6pthread_mutex_t *mtx;
7const int kStride = 16;
8
9void thread(int tid) {
10 for (int i = 0; i < bench_niter; i++) {
11 pthread_mutex_lock(&mtx[tid * kStride]);
12 pthread_mutex_unlock(&mtx[tid * kStride]);
13 }
14}
15
16void bench() {
17 mtx = (pthread_mutex_t*)malloc(bench_nthread * kStride * sizeof(*mtx));
18 for (int i = 0; i < bench_nthread; i++) {
19 pthread_mutex_init(&mtx[i * kStride], 0);
20 pthread_mutex_lock(&mtx[i * kStride]);
21 pthread_mutex_unlock(&mtx[i * kStride]);
22 }
23 start_thread_group(bench_nthread, thread);
24}
25
26// CHECK: DONE
27