Below is another modification to Petersons algorithm Does it

Below is another modification to Peterson’s algorithm. Does it solve the critical section problem?

do

{ flag[i] = true; turn = j;

while (!(flag[j] || turn == j)) ;

/* critical section code */ flag[i] = false;

/* remainder section */ } while (true)

Solution

No, the above petersons alogorithm is not used to solve the crirical section prolem because it have to execute until false.

repeat

    flag[i]:=true;
    while flag[j]
        do if turn = j
            then begin
                    flag[i]:=false;
                    while turn = j do no-op;
                    flag[i]:=true;
            end;

      critical section

     turn := j;
    flag[i]:=false;

    remainder section

until false;

Below is another modification to Peterson’s algorithm. Does it solve the critical section problem? do { flag[i] = true; turn = j; while (!(flag[j] || turn == j)

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site