Mandar Mitra
unread,Apr 22, 2025, 4:41:42 AMApr 22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rahul Bhattacharya, isi-mt...@googlegroups.com
Rahul Bhattacharya wrote (Mon, Apr 21, 2025 at 01:24:32PM +0530):
> What is the difference between algorithm 3 and incorrect solutions except
> interchange of the lines “want[i]=1” and “turn=j” in the “Two-process
> solutions”. And how does this interchange effect?
That was the point of these examples: to show that the location of the turn = j statement is very important.
The algorithm works only if turn is set to j immediately after want[i] = 1 (slide 10/31).
If turn is set to j immediately before want[i], then Mutual Exclusion may be violated. The interleave given at the bottom of the slide (11/31) shows how both processes may end up in the critical section in this case.
Similarly, if turn = j is done after the critical section, then also Mutual Exclusion may be violated.