β All resources
π Source slides β
π Interleaving Lab
β concurrency non-determinism
Run concurrent threads over shared variables and see
every possible interleaving
, how many there are, and how many
distinct outputs
result β the heart of race conditions. Each line in a thread is one
atomic
statement.
Presets:
Exam Q3 (multiply/add Γ4)
Lost update (x++ Γ2)
Simple 2-thread
Initial shared vars
+ Thread
Serialize each thread (mutex β no interleaving inside a thread)
Possible interleavings
β
Distinct outputs
β
Outcomes
Trace one interleaving