This Screenshot is taken from William Stalling's Operating Systems book. My doubt is that Bounded wait is not satisfied by this solution.
For example: P0 and P1 both want to enter critical section and set their flags to true.
flag = 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=false.
Now actual problem starts from here:
Process P1 comes out of infinite while loop and before i 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!