Re: Confusion in synchronisation

10 views
Skip to first unread message

Mandar Mitra

unread,
Apr 22, 2025, 4:41:42 AMApr 22
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.
Reply all
Reply to author
Forward
0 new messages