Quantcast
Channel: Active questions tagged operating-system+scheduling - Stack Overflow
Viewing all articles
Browse latest Browse all 211

In dekker's algorithm, can i remove the last instruction flag[ i ] = false?

$
0
0

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.


Viewing all articles
Browse latest Browse all 211


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>