Considering two processes, 0 and 1, and the program for the process 0:
do
{
flag[0]= true;
while(flag[1]==true)
{
if(turn!=0)
{
flag[0] = false;
while(turn!=0);
flag[0] = true;
}
}
// CS
turn = 1;
flag[0] = false;
}while(true);
What is the purpose of the last line flag[0] = false? Why can't it be removed? It will go back to the first line flag[0] = true and nothing happened because of it.