Bas van den Heuvel
2024-05-10
See lecture notes.
In the literature referred to as Correct Trace Reordering.
Two requirements:
We have seen Lock-semantics condition:
Lock-1: if , then there exists in .
Lock-2: if , then there exists such that and there is no in . That is, we have .
Additionally, we have Fork-join condition:
Fork-1: for each thread (not the main thread), there exists at most one in , and there is no in .
Fork-2: for each event in thread , there exists in thread and .
Join: for each in thread we have and, for each event in , .
We often omit events, assuming all threads are initially forked by the main thread.
HB additionally requires:
If , then, for each , .
Recall thread projection: is the list of events in thread contained in trace .
If , then, for each , .
We have seen:
Program-order condition:
The condition requires, for each thread , that .
Last-writer condition:
For each read in , the last-writer of is the same in and .
HB, ESs, and Set-based Race Predictor.
T1 T2 ES
e1. fork(T2)
e2. wr(x)
e3. rd(x)
e4. rd(x)
e5. wr(x)
HB: and .
T1 T2 ES
e1. fork(T2) {1}
e2. wr(x) {1,2}
e3. rd(x) {1,2,3}
e4. rd(x) {1,4}
e5. wr(x) {1,4,5}
T1 T2 ES
e1. fork(T2)
e2. wr(x)
e3. wr(y)
e4. rd(y)
e5. wr(x)
HB: and .
T1 T2 ES
e1. fork(T2) {1} D(T1) = {1} ; D(T2) = {1}
e2. wr(x) {1,2} D(T1) = {1,2} ; W(x) = 2
e3. wr(y) {1,2,3} D(T1) = {1,2,3} ; W(y) = 3
e4. rd(y) {1,4} W(y) notin D(T2) ; R(y) = {4} ; D(T2) = {1,4}
e5. wr(x) {1,4,5} W(x) notin D(T2) ; D(T2) = {1,4,5} ; W(x) = 5
T1 T2 ES
e1. fork(T2)
e2. wr(a)
e3. acq(x)
e4. wr(b)
e5. rel(x)
e6. wr(c)
e7. acq(x)
e8. rd(a)
e9. rd(b)
e10. rel(x)
e11. wr(c)
HB: , , and .
T1 T2 ES
e1. fork(T2) {1} D(T1) = {1} ; D(T2) = {1}
e2. wr(a) {1,2} D(T1) = {1,2} ; W(a) = 2
e3. acq(x) {1,2,3} D(T1) = {1,2,3}
e4. wr(b) {1,2,3,4} D(T1) = {1,2,3,4} ; W(b) = 4
e5. rel(x) {1,2,3,4,5} D(T1) = {1,2,3,4,5} ; Rel(x) = {1,2,3,4,5}
e6. wr(c) {1,2,3,4,5,6} D(T1) = {1,2,3,4,5,6} ; W(c) = 6
e7. acq(x) {1,2,3,4,5,7} D(T2) = {1,2,3,4,5,7}
e8. rd(a) {1,2,3,4,5,7,8} R(a) = {8} ; D(T2) = {1,2,3,4,5,7,8}
e9. rd(b) {1,2,3,4,5,7,8,9} R(b) = {9} ; D(T2) = {1,2,3,4,5,7,8,9}
e10. rel(x) {1,2,3,4,5,7,8,9,10} D(T2) = {1,2,3,4,5,7,8,9,10} ; Rel(x) = {1,2,3,4,5,7,8,9,10}
e11. wr(c) {1,2,3,4,5,7,8,9,10,11} W(c) notin D(T2) ; D(T2) = {1,2,3,4,5,7,8,9,10,11} ; W(c) = 11
T1 T2
e1. fork(T2)
e2. acq(x)
e3. wr(a)
e4. rel(x)
e5. acq(x)
e6. rd(a)
e7. rel(x)
HB: , , and .
T1 T2
e1. fork(T2) D(T1) = {1} ; D(T2) = {1}
e2. acq(x) D(T1) = {1,2}
e3. wr(a) D(T1) = {1,2,3} ; W(a) = 3
e4. rel(x) D(T1) = {1,2,3,4} ; Rel(x) = {1,2,3,4}
e5. acq(x) D(T2) = {1,2,3,4,5}
e6. rd(a) D(T2) = {1,2,3,4,5,6} ; W(a) = 6
e7. rel(x) D(T2) = {1,2,3,4,5,6,7} ; Rel(x) = {1,2,3,4,5,6,7}
T1 T2
e1. fork(T2)
e2. acq(l)
e3. wr(x)
e4. rel(l)
e5. acq(l)
e6. wr(x)
e7. rel(l)
e8. rd(x)
HB: , , and .
Correct reordering with a data race:
T0 T1
e1. fork(T1)
e5. acq(l)
e6. wr(x)
e7. rel(l)
e2. acq(l)
e8. rd(x)
e3. wr(x)
e4. rel(l)
T1 T2 T3
e1. fork(T3)
e2. acq(l)
e3. fork(T2)
e4. wr(x)
e5. join(T2)
e6. rel(l)
e7. acq(l)
e8. wr(x)
e9. rel(l)
e10. rd(x)
HB: , , , and .
Correct reordering with a data race: ~~~ T0 T1 T2
e1. fork(T2)