title: Semaphore execution
body: <p>P1 and P2 are two concurrent processes interacting over shared data as shown below.Tell me whether the property of mutual exclusion is satisfied for the given codes or if not,provide a corrected version that satisfies the mutual exclusion property.</p>
  
  <pre><code>do {
  signal(mutex);
  // critical section
  wait(mutex);
  // remainder section
  } while (TRUE);
  </code></pre>
  
  <p>Code for P2:</p>
  
  <pre><code>do {
  wait(mutex);
  // critical section
  signal(mutex);
  // remainder section
  } while (TRUE);
  </code></pre>
  
  <p>Note:
  The definition of wait() is as follows:</p>
  
  <pre><code>wait(S) {
  while S &lt;= 0
  ; // no-op
  S-- ;
  }
  </code></pre>
  
  <p>The definition of signal() is as follows:</p>
  
  <pre><code>signal(S) {
  S++;
  }
  </code></pre>