Hello,
I'm trying to understand algorithm to this mutual exclusion problem/example:
Code:
repeat
(while turn != 0);
// critical section
turn = 1;
// non-critical section
until false;
repeat
(while turn != 1);
// critical section
turn = 0;
// non-critical section
until false;
Why is there a ; after the while statement as if its doing nothing? Does the statement after ; still get executed?
It seems a bit backwards to me. Every example of this solution I see implemented this way.
Why dont they write
Code:
(while turn == 1){
// critical section
}
(while turn == 0){
// critical section
}
This seems to be straight forward. Am I missing something here?