title: Understanding wait() and signal()
body: <p>I have 2 processes P1 and P2 that share 3 semaphores (s1, s2, s3) each with an initial value of 1 and also 3 variables (x, y, z)</p>
  
  <pre><code>P1:                  P2:
  wait(s1);            wait(s2);  
  x = x + 1;           y = y * 2;
  wait(s2);            wait(s3);
  y = y - x;           z = z - y;
  wait(s3);            signal(s2);
  z = x + 2 * y - z;   wait(s1);
  signal(s3);          x = x + 2;
  signal(s2);          signal(s1);
  signal(s1);          signal(s3);
  </code></pre>
  
  <p>If I were to run them concurrently on a computer with a single CPU, is it possible for P1 and P2 to get into a deadlock?</p>
  
  <p>How I look at it is that as soon as they start running, they both wait() which causes them to sit until something signals() them. Since nothing else is running, then aren't they both in deadlock? I feel I am missing some critically simple knowledge that is hindering my understanding. Any insight is appreciated!</p>