David
2009-10-25 12:07:37
A:
@Dvaid:Thanks for your kindly reply.But what about the second question,I mean how could turn == 0 and p0 in its remainder section exist concurrently?
Jichao
2009-10-25 14:41:05
Ah, sorry about that - I thought it would've been clear from my description of the problem above. If it was P1 that just finished executing its critical section (instead of P0, as in my example above) then P1 would set `turn = 0`. Now, you seem to be assuming that P0 must be waiting to enter its critical section at this time (in which case it will now be able to enter it, since `turn == 0`), but actually it could be doing something completely different, which could take some time. When it eventually does want to enter its critical section, `turn == 0` will still be true.
David
2009-10-25 18:58:33