edited by
3,278 views
3 votes
3 votes
while(1) 
{ 
    flag[i] = true; 
    while(flag[j]); 
    /* Critical section */ 
    flag[i] = false; 
    /*Remainder section */ 
    
}

Let flag is declared as Boolean flag[2] and Pi denote one process while Pj denotes other process and i = 1-j. Both processes execute concurrently, then in the above case

A) Mutual Exclusion is satisfied only

B) Mutual Exclusion and Bounded Waiting is satisfied only

C) Progress is satisfied only

D) Mutual Exclusion and Progress is satisfied only

edited by

1 Answer

Best answer
5 votes
5 votes

Mutual exclusion and Bounding waiting is satisfied here, progress not.

Mutual exclusion because no two processes can enter critical section at the same time. If one process is in the critical section, then other has to wait.

Bounding waiting because when a process shows the interest to go into the critical section then there is bound on the number of time other processes can go into the critical section and that is 1. (Process is already in the critical section).

Progress is not satisfied here because when both the process execute Flag[i] = true and got preempted then both the processes waiting for each other to release the flag. Which is not going to happen without entering the critical section. So They will wait for indefinite time, No progress. This situation is called "Deadlock".

selected by

Related questions

0 votes
0 votes
2 answers
1
shivajikobardan asked Jul 22, 2023
797 views
Sorry if this is a stupid question. But it really intrigued me. Same resources at different algorithms are telling different ways to test these stuffs.Here's an algorith...
1 votes
1 votes
1 answer
2
gari asked Jan 3, 2018
570 views
Deadlock no progressDoes progress - no deadlock...?
12 votes
12 votes
1 answer
3