lets suppose Pi wants to enter in critical section so it set its flag=true and now suppose at the same times other two does not want to enter the critical section so the program does not enter in the while loop and process Pi went to critical section and after coming out of critical section it will give turn to Pj
because
if turn = i then turn := j;
flag [i] := false
non-critical section
now suppose Pj want to enter the critical section same thing will happen (if other two does not want to enter in critical section ) and it will give turn to Pk . and pk give turn to its next i.e. Pi
now consider another scenario where Pj does not want to enter the critical section and Pk is waiting and Pi is in critical section and after coming out of critical section Pi set own flag false and turn =j
now suppose pj does not want to enter the critical section then how the Pk can enter
please correct me i am wrong