1 /* { dg-set-target-env-var TSAN_OPTIONS "halt_on_error=1" } */
2 /* { dg-shouldfail "tsan" } */
8 #define MAX_ITERATIONS_NUMBER 100
9 #define SLEEP_STEP 128000
11 unsigned int delay_time
= 1000;
13 static inline void delay () {
21 for (i
= 0; i
< MAX_ITERATIONS_NUMBER
; i
++) {
23 delay_time
+= delay_time
< 256000 ? delay_time
: SLEEP_STEP
;
30 void *Thread1(void *x
) {
36 void *Thread2(void *x
) {
43 pthread_create(&t
[0], NULL
, Thread1
, NULL
);
44 pthread_create(&t
[1], NULL
, Thread2
, NULL
);
45 pthread_join(t
[0], NULL
);
46 pthread_join(t
[1], NULL
);
50 /* { dg-output "WARNING: ThreadSanitizer: data race.*(\n|\r\n|\r)" } */