title: One consumer and any of two producers
body: <p>I am having trouble writing this C code where I need to have two producers with their own buffers. and then one consumer which consumes one item from either buffer and only waits if both buffers are empty. I know how to write the code for if the consumer waits if either producer buffer is empty,</p>
  
  <pre><code>sem_wait(Xfull);
  item1 = BufferX[outX];
  sem_signal(Xempty);
  
  sem_wait(Yfull);
  item2 = BufferB[outY];
  sem_signal(BufferBEmpty);
  </code></pre>
  
  <p>But I'm stuck on this.</p>