dimanche 11 janvier 2015

Critical section example with 2 processes


Vote count:

0





P0 P1
------ -------
do { do {
flag[0] = 1; flag[1] = 1;

while(flag[1]) while(flag[0])
{ {

} }

( Critical Section ) ( Critical Section )

flag[0] = 0; flag[1] = 0;

( Remainder Section) ( Remainder Section)

} }
while(1); while(1);


I want to check whether above code satisfies Mutual Exclusion , Progress, Deadlock and Bounded Waiting or not ??


Mutual Exclusion : It satisfies Mutual Exclusion. because if they started concurrently , they will be trapped in "While" loop. So their sequence must be , one after another.


Progress : As per my understanding Progress is , While checking condition for Critical Section , particular process should consider those process's which are interested in critical section, other process should not be entertained. After exiting from Remainder section , if P0 is not interested in executing again but still P1 , is checking P0's flag to enter critical section. So violating rule. So No Progress. ( Is it correct thinking ??? )


Deadlock : If P0 and P1 executed simultaneously at the start , then both will stuck in While loop , so deadlock.


Bounded Waiting : ????


Above 3 thoughts are not matching with answer. Please correct me.



asked 50 secs ago







Critical section example with 2 processes

Aucun commentaire:

Enregistrer un commentaire