Synchronization & Concurrency


Answer & solution
Answer: Mutual exclusion fails after reordering, but there is no resource deadlock (no official key was published)
After swapping the the paper operations, both processes check/set R1 and then check/set R2. Name the new P2 order Q1′=test R1, Q2′=set R1, Q3′=test R2, Q4′=set R2, followed by use and the original releases. A violating interleaving is S1,Q1′,S2,Q2′,S3,Q3′,S4,Q4′, followed by overlapping S5 and Q5. Both tests of each free flag precede either write to that flag, so both reach their use intervals. This shows why a real atomic lock operation is required.
There is no resource deadlock in the reordered the paper protocol: a process waiting on R2 has already passed the R1 test. Any competing process that made R2 busy has also passed both tests and can finish and release; it cannot be waiting to acquire R1 afterward. This excludes a circular resource wait, assuming a runnable process eventually runs. It does not promise fairness or fix mutual exclusion.
Its one-shot nonoverlap and self-wait deadlock from parts (a),(b) remain.