4,516 views
2 votes
2 votes
How to check for bounded waiting???will there be deadlock??...I know in this code mutual exclusion is satisfied but progress is not satisfied!!!
Consider the following code:-
i = 0, j = 1 and initially both flags are false.
do { flag[i] = true;
while(flag[j]);
Critical Section
flag[i] = false;
remainder section
} while(1);

2 Answers

Best answer
3 votes
3 votes
Deadlock is possible... When flag[I]= true and flag[j] = true..

Process 0: Make flag[I] =true and than preempted now process 1: enter and make flag[j] = true ..

So no one enter into critical section...

Bounded waiting : when only single process gets the turn to enter into critical section every time even other process are also interested with critical section..

So there should be bound on no.of time particular process can enter into critical section...
selected by
0 votes
0 votes
from my point of view neither progress not bounded waiting is satisfied

Progress: If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder section can participate in deciding which will enter its critical section next, and this selection cannot be postponed indefinitely.

Bounded waiting: There exists a bound, or limit, on the number of times other processes are allowed to enter their critical sections after a process has made request to enter its critical section and before that request is granted.

so here the supposs p0 and p1 make there flag = true, both of the process wish to enter the critical section but non of them will enter  and also bounded waiting is not satified as you can see in the code

Related questions

0 votes
0 votes
2 answers
1
shivajikobardan asked Jul 22, 2023
893 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...
0 votes
0 votes
2 answers
3
radha gogia asked Aug 23, 2018
1,737 views
When BW isn't satisfied , it imply that process will wait for indefinite period of time , so obviously we will have starvation , so how come they both are not related to ...
0 votes
0 votes
0 answers
4
Parimal Paritosh asked Aug 18, 2018
1,108 views
Does Semaphore satisfy bounded waiting? If so, how?