in Operating System
1,229 views
1 vote
1 vote

Consider the following algorithm as a solution to the Critical Section problem.


The process shares two variables:
var flag: array [0….1] of Boolean;
turn= 0…..1;
Initially flag [0]= flag [1]= false;
turn= 0 (or) 1;
the structure of process Pi is like
repeat
flag[i] = true;
turn= j;
while (CONDITION);
CS
flag [i]= false;
………
………
until false.


What should be the Condition, so that algorithm satisfies all the three requisites i.e. ME, Progress
& BW?
(a) flag [j]= true & turn= j; (b) flag [j]= false & turn= i;
(c) flag [i]= true & turn= j; (d) flag [i]= false & turn= i;


Solution: Option (a)  (need the explanation)

in Operating System
by
1.2k views

1 Answer

1 vote
1 vote
Best answer

This a typical case for Peterson's Solution:

Although, this is quite easy topic, I would recommend to go through Galvin for better understanding.

selected by

Related questions