1

I read this link https://en.m.wikipedia.org/wiki/Producer–consumer_problem#Using_semaphores

Here they have said that the difference between mutex and binary semaphore is that mutex uses concept of "ownership" which means the process which decrements the variable can only increment it.

Can anyone tell me a situation or an instance when mutex is appropriate and binary semaphore will fail? I think that using a binary semaphore will always guarantee mutual exclusion

Zephyr
  • 1,521
  • 3
  • 22
  • 42
  • 2
    Possible duplicate of [Difference between binary semaphore and mutex](https://stackoverflow.com/questions/62814/difference-between-binary-semaphore-and-mutex) – Tony Tannous Jun 10 '17 at 16:33
  • I read your link. I understand the difference between the two. I just want to know in which situation a binary semaphore can fail and mutex is preferred – Zephyr Jun 10 '17 at 17:01
  • 1
    But what are *your* definitions of "mutex" and "binary semaphore"? These terms name abstractions but are also used by particular systems with their own special meanings. If you can't define your terms then you haven't said anything. See my comment on the question at [Difference between binary semaphore and mutex](https://stackoverflow.com/questions/62814/difference-between-binary-semaphore-and-mutex). Eg wiki Locks equates lock & mutex and says "The simplest type of lock is a binary semaphore." Wiki Semaphore re Semaphores vs. mutexes says fuzzy pseudo-stuff then POSIX-thread-specific stuff. – philipxy Jul 05 '17 at 04:20

0 Answers0