[ASan/Win] Add a comment about DCL-using-static vs threads
[blocksruntime.git] / test / tsan / bench_mutex.cc
blob324d53fd7f28d725c94e56f5ed69f8d77dbc7f05
1 // RUN: %clangxx_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s
4 #include "bench.h"
6 pthread_mutex_t mtx;
7 pthread_cond_t cv;
8 int x;
10 void thread(int tid) {
11 for (int i = 0; i < bench_niter; i++) {
12 pthread_mutex_lock(&mtx);
13 while (x != i * 2 + tid)
14 pthread_cond_wait(&cv, &mtx);
15 x++;
16 pthread_cond_signal(&cv);
17 pthread_mutex_unlock(&mtx);
21 void bench() {
22 pthread_mutex_init(&mtx, 0);
23 pthread_cond_init(&cv, 0);
24 start_thread_group(2, thread);
27 // CHECK: DONE