title: Producer-Consumer model - binary semaphore or mutex?
body: <p>This is mainly about the understanding of the concept, which confuses me.  </p>
  
  <p><strong>Mutex</strong> means that one thread takes the control of the access of shared resource, performs operations and unlocks it, then only other thread can gain access to lock  </p>
  
  <p>while <strong>binary semaphore</strong> is like a thread can gain access to the shared resource but gaining access to the lock, while another thread can unlock it  </p>
  
  <p>In the last question that I saw over <a href="https://stackoverflow.com/questions/62814/difference-between-binary-semaphore-and-mutex">here</a>, it was mentioned that <code>"semaphores are more suitable for some synchronization problems like producer-consumer".</code>  </p>
  
  <p>My <strong>question</strong> is, for example, if producer thread has gained lock and filling up some queue with data, and consumer at the same time unlocks it, isn't there any concurrency issue??  </p>