edited
3,826 views
4 votes
4 votes

This Screenshot is taken from William Stalling's Operating Systems book. My doubt is that Bounded wait is not satisfied by this solution. Though Book claims that is satisifes all three required conditions.

For example: P0 and P1 both want to enter critical section and set their flags to true.

flag[0] = true

flag[ 1] = true

Both p0 and p1 enter while loop, p0 wins the race process P1 sets its flag to false

now flag[ 1]= false

Process P0 goes into Critical Section, comes out, sets turn = 1 and flag[0]=false.

Now actual problem starts from here:

Process P1 comes out of infinite while loop and before it could set flag[ 1] to True from False, it gets preempted.

Now Process P0 can go any number of times in Critical section because Flag[ 1] is False.

Conclusion: Process P1 tried to get access to critical section but because of bad solution it did set its flag to False to give path to Po and now stuck for infinite time.

hence B.W is not satisfied!

edited

1 Answer

Best answer
0 votes
0 votes

Though Book claims that is satisifes all three required conditions.

Yes, in Stallings , it defined BW based on infinite waiting time .. ( the definition says : no process should wait for a resource for infinite amount of time . )

For this case , you can see deadlock is there so BW is not satisfy as there is indefinite waiting.

But there are another way we can define BW ( The Galvin definition ), in terms of number of other process in CS ( what we need to follow  )

And here BW is satisfied if we consider this definition ... when u check BW satisfied or not just check before our requesting process how many other process can go to CS or how many times other process can go to CS ! thats it.

So you see there are 2 way we can define BW, in one case BW not satisfy and in other case BW does satisfy .

For 2nd case we just need to check for each process before it enter how many other process can enter into CS ( this is rather more simple way to check , here we don't consider that the system is in deadlock or no progress possible ..etc , we just check when a process request and before that request granted how many other process enter into CS ) .

When there are 2 process and there is strict alternation ( means after p1 , p2 must come) BW never get dissatisfied.

--------

Read this thread once :

selected by

Related questions

0 votes
0 votes
1 answer
1
N3314nch41 asked Sep 10, 2023
361 views
How to approach synchronization (specifically semaphore) question, there size are really intimidating and i’m unable to decode the code written? What to do??
0 votes
0 votes
0 answers
2
Nirmal Gaur asked Dec 19, 2018
556 views
Does Progress implies freedom from Deadlock?