edited by
711 views
0 votes
0 votes

Consider the following solution for critical section problem with 'n' processes P0,P1,P2,......P(n-1).For all i,number[i] is an integer array initialized to zero, and for all j,choosing[j] is a binary array initialized to false.

                        

CODE FOR Pi :

     Repeat   {

       choose[i]=true;
       
       number[j]= max(number[0],number[1],.......................number[n-1])+1;

       choosing[i]=false;

        for j=0 to n-1

        do begin

        while(choosing[j]) do nothing;

        while(number[j]!=0 and (number[j],i) < (number[i], i))

        do nothing;

        end;

        critical section;

         number[i]=0;

         remainder section;

         }until false;


consider the following statements about above solution:

S1:solution preserve first come first serve property.

S2:solution follows mutual exclusion condition.

S3:solution leads to starvation.

Which of the following is correct.

a)S1 only.

b)S1 and S2 only.

c)S2 and S3 only.

d)S1 , S2 and S3

(please anyone elaborate this solution.thanks in advance)

edited by

1 Answer

0 votes
0 votes

This is an extended question from this https://gateoverflow.in/39719/gate2016-1-50

while(number[j]!=0 and (number[j],i) < (number[i], i))

This line specifies that, if two process has same value, Suppose P2=2 and P3=2, then among i and j , which one will has less value will execute first. Here P2 index value is less So, it will execute first. So, it will be guaranteed Mutual Exclusion. Also it will execute FCFS manner. But there should not be any Starvation.

So, ans B)

Refer:https://gateoverflow.in/283766/self-doubt

https://gateoverflow.in/blog/342/algorithm-solution-critical-section-processes-explanation

 

Related questions

1.1k
views
0 answers
4 votes
atulcse asked Jan 19, 2022
1,094 views
Consider the following proposed solution to Dining Philosopher's problem to avoid deadlock. The binary semaphore lock is initialized to 1.Which of the following is correct ... (iv) are necessary. Removal of any of them will affect the code.
685
views
0 answers
3 votes
junk_mayavi asked Jan 2, 2018
685 views
Let 'n' processes competing to enter their critical sections and mutex be a global binary semaphore initialized to 1. The process is coded as follows:Signal( ... competition to enter as well. can we take this as progress?Please answer.
2.0k
views
1 answers
1 votes
mahakp asked Jan 5, 2018
2,044 views
Q1. Consider the methods used by process P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared Boolean ... D will not satisfy mutual exclusion? I am confused between B and D.