title: peterson's solution for critical section problem
body: <pre><code>#include&lt;stdio.h&gt;
  #include&lt;sys/types.h&gt;
  #include&lt;stdlib.h&gt;
  int turn;
  int flag[2];
  int main(void)
  {
          int pid,parent=1;
          printf("before vfork\n");
          if((pid=vfork())&lt;0)
          {
                  perror("vfork error\n");
                  return 1;
  
          }
          while(1)
          {
                  if(pid==0)
                  {
                       while(parent==1)
                       {
                        sleep(2);
                       }
                       parent=0;
                       flag[0]=1;
                       turn=1;
                       while(flag[1]&amp;&amp;turn==1);
                       printf("This is critical section:parent process\n");
                       flag[0]=0;
                  }
                  else
                  {
                          parent=2;
                          printf("This is parent");
                          flag[1]=1;
                          turn=0;
                          while(flag[0]&amp;&amp;turn==0);
                          printf("This is critical section:child process %d \n",pid);
                          flag[1]=0;
                  }
          }
  
  }
  </code></pre>
  
  <p>This is my code. Can anyone tell why control is not coming to my parent process.</p>