1,496 views
1 1 vote
Consider Peterson's algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process is shown below.

repeat
    flag[i] = true;
    turn = j;
    while (P) do no-op;
    Enter critical section, perform actions, then
    exit critical section
    Flag[i] = false;
    Perform other non-critical section actions.
Until false;
For the program to guarantee mutual exclusion, the predicate P in the while loop should be

1)flag[j] = true and turn = i
2)flag[j] = true and turn = j
3)flag[i] = true and turn = j
4)flag[i] = true and turn = i

1 Answer

0 0 votes

the correct answer is Option B

Position:
Show:

Related questions

3 3 votes
1 1 answer
268
268 views
GO Classes asked Jul 25
268 views
Which of the following statements are correct?Mutual exclusion ensures that if one process is executing in its critical section, no other process can execute in its criti...
2 2 votes
3 3 answers
329
329 views
0 0 votes
1 1 answer
593
593 views
0 0 votes
0 0 answers
444
444 views
air1air2 asked Nov 29, 2024
444 views
Does this satisfy bounded waiting .The answer is given it does not satisfies bounded waiting but if P0 exits the critical section and p1 want to enter then the cs gets bl...