Synchronization & Concurrency

Answer & solution
Official answer: 80
Method: split each assignment into a read, local arithmetic, and write; an interrupted process may later overwrite a newer shared value using its earlier read.
1. To attain the minimum, let P2 read 100 and compute 50 but delay its write. Let P1 and P3 complete their increments, then let P2 write its stored 50 last. The final result is 50, because the earlier increments are overwritten.
2. To attain the maximum, let P1 and P2 both read 100. P2 writes 50 first; P1 then writes its stored 120, overwriting the decrement. P3 reads 120 and writes 130. The final result is 130.
3. These are also bounds. Trace the final write back through the value read by its writer, and recursively through preceding writes. This dependency chain starts at 100 and can include each process's change at most once. Its smallest possible sum includes −50 but no positive changes, giving 50; its largest includes +20 and +10 but not −50, giving 130.
4. Both bounds are attainable by steps 1 and 2, so X=50 and Y=130. Their difference is 130−50=80.
Result: 80. If whole assignments were atomic, every order would instead end at 80; the intended model permits preemption within an assignment. Under that different atomic model X=Y=80 and Y−X would be zero. A uniprocessor prevents simultaneous instruction execution but does not by itself make a multi-instruction update atomic.