title: Dining philosophers using binary semaphores
body: <p>Can this pseudocode solve the dining philosopher problem with maximum parallelism? Here <code>mutex</code> is a binary semaphore initialized to 1. Forks are assumed to be numbered from 0 to (N-1). There are a total of N philosophers numbered from 0 to (N-1).    </p>
  
  <pre><code>void philosopher(int i)    // ith philosopher
  {   
     while (true)
     {
          think();
          down(&amp;mutex);          // acquire lock
          take_fork(i);            // take left fork
          take_fork((i+1)%N);        // take right fork
          up(&amp;mutex);          // release the lock
          eat();
          down(&amp;mutex);       // acquire lock
          put_fork(i);
          put_fork((i+1)%N);
          up(&amp;mutex);        // release the lock
     }    
  }
  </code></pre>
  
  <p>This should solve the dining philosopher problem with maximum parallelism, because the lock is released after one philosopher has acquired both forks. But will it? And will there be any issue of liveliness? I am confused.</p>