File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ void wait_until_uncomfortable() {
14
14
// stoic philosophers are always comfortable
15
15
}
16
16
17
+ [[gnu::noinline]] // prevent compiler optimization
17
18
void poop_into (int stall) {
18
19
stalls[stall] += 1 ;
19
20
}
@@ -35,4 +36,9 @@ int main() {
35
36
}
36
37
37
38
sleep (5 );
39
+
40
+ // NB: data races here
41
+ for (int i = 0 ; i != K; ++i) {
42
+ printf (" stalls[%d] = %llu\n " , i, stalls[i]);
43
+ }
38
44
}
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ void wait_until_uncomfortable() {
14
14
// stoic philosophers are always comfortable
15
15
}
16
16
17
+ [[gnu::noinline]] // prevent compiler optimization
17
18
void poop_into (int stall) {
18
19
stalls[stall] += 1 ;
19
20
}
@@ -36,4 +37,9 @@ int main() {
36
37
}
37
38
38
39
sleep (5 );
40
+
41
+ // NB: data races here
42
+ for (int i = 0 ; i != K; ++i) {
43
+ printf (" stalls[%d] = %llu\n " , i, stalls[i]);
44
+ }
39
45
}
You can’t perform that action at this time.
0 commit comments