title: Semaphore signalling vs mutex
body: <p>I was looking over some topics that describes the difference between mutex and binary semaphore. In many topics it is stated that semaphore act as a signalling mechanism i.e if a thread has locked a semaphore then another thread can unlock(release) the semaphore(acting as signal).
  But in case of mutex only the thread that locks the mutex can unlock it .It can't be unlocked by any other thread and if other thread tries to unlock it this will return error.</p>
  
  <p>I have tried writing a code that uses mutex for synchronization. In the code I am locking the mutex in one thread and successfully unlocking the mutex in other thread.
  Can someone please explain how this can happen.According to the answers everywhere  the other thread should not be able to unlock mutex.</p>
  
  <p>Any suggestions are most welcome.</p>