edited by
1,613 views
3 votes
3 votes
Consider the below Algorithm:

P0: Process= 0                                                    P1: Process= 1
other= 1-Process                                                 other= 1-Process
while (flag!= Process);                                         while (flag!= Process);
Enter CS                                                              Enter CS
………                                                                  ………
………                                                                  ………
flag= other.                                                           flag= other.

(a) The algorithm guarantees Mutual Exclusion
(b) The algorithm is busy waiting solution
(c) The algorithm does not guarantee progress
(d) The algorithm guarantee Bounded waiting
edited by

4 Answers

6 votes
6 votes

If the question was which of these is/are True then option a,b,c and d all are true...

i) Used Loop Controls =====> Busy Waiting Solution...

ii) After Updating local variable other only both processes are going into loop ===> only one can enter ==> Mutual Exclusion Guarantee

iii) the sequence of execution is

           p0,p1,p0,p1,p0,p1,p0,..... ( if Flag=0 initially )

           p1,p0,p1,p0,p1,p0,p1,..... ( if Flag=1 initially )

      in both cases no long waiting ====> Bounded waiting ( waiting time = 1 ===> strict alternation )

iv) if the p0 enter into CS and exit flag updated then it only allows p1 to enter.. if P1 doesn't want to enter... then even p0 wants to enter it can't ====> not guarantee progress

1 votes
1 votes
Option A

As the code only allows only one process to be in critical section.
1 votes
1 votes
(b) The algorithm is busy waiting solution

This option is also true along with option A.

option b. is true because while loop create busy waiting it will continusly checking.
0 votes
0 votes
Answer: A,C,D

Option (B) is not included as we can see if process 0 is using critical section then process 1 is in waiting state which mean it continuously iterating the while to check condition till the flag become 1, so this is note the solution for busy waiting, for busy waiting solution we use semaphore,
edited by

Related questions

0 votes
0 votes
1 answer
1
ajayraho asked Oct 23, 2022
911 views
What is the significance of infinite loop that is written in every example of process synchronisation? What would happen if there wasn't any infinite loop?