1 // RUN: %clang_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
4 #include "dispatch/dispatch.h"
10 int main(int argc
, const char *argv
[]) {
11 dispatch_semaphore_t done
= dispatch_semaphore_create(0);
12 dispatch_queue_t target_queue
= dispatch_queue_create(NULL
, DISPATCH_QUEUE_SERIAL
);
13 dispatch_queue_t q1
= dispatch_queue_create(NULL
, DISPATCH_QUEUE_CONCURRENT
);
14 dispatch_queue_t q2
= dispatch_queue_create(NULL
, DISPATCH_QUEUE_CONCURRENT
);
15 dispatch_set_target_queue(q1
, target_queue
);
16 dispatch_set_target_queue(q2
, target_queue
);
18 for (int i
= 0; i
< 100000; i
++) {
22 if (global
== 200000) {
23 dispatch_semaphore_signal(done
);
29 if (global
== 200000) {
30 dispatch_semaphore_signal(done
);
35 dispatch_semaphore_wait(done
, DISPATCH_TIME_FOREVER
);
36 fprintf(stderr
, "Done.\n");