edited by
883 views
1 votes
1 votes

Consider the following variation in Peterson’s solution for 2 processes.

shared char want[2] = {0,0};
shared int turn = 0;
1. P_i()
2.  { while (1) {
3.      turn = |1-i|;
4.      want[i] = 1;
5.      while (want [j] && turn!=i);
6.      critical_section();
7.      want[i] = 0;
8.      remainder_section();
9.   }
10. }


Which of the following statements is/are true?
i) Mutual exclusion guaranteed
ii)Progress is achieved

  1.   Both i and ii
  2.   Only i
  3.   Only ii
  4.   None

for ME,I got the solution but couldn't understand about progress.Please explain.

edited by

1 Answer

2 votes
2 votes

Progress: The process which is not interested to enter in Critical Section should not stop the other processes to enter CS

If any process doesn't want to go to CS, then it will make want = false, i,e. any other process can go to CS, bcz for other process want[j] will become false and while loop will break.

Related questions

1 votes
1 votes
4 answers
1
Purple asked Jan 29, 2016
7,784 views
Which of the following is not a necessary condition for a deadlock among processes?(a) Shared Resources(b) No Preemption(c) Acyclic condition among processes(d) None of t...
2 votes
2 votes
1 answer
3