Explain the difference between mutex and semaphore.

  • Binary
  • Counting
  • Mutual Exclusion
  • Synchronization
Mutex and semaphore are both synchronization mechanisms, but they serve different purposes. A mutex ensures mutual exclusion, allowing only one thread to access a resource at a time, while a semaphore can allow multiple threads to access multiple resources concurrently. Mutexes typically use binary values (0 and 1) to signal resource availability, while semaphores can have a count greater than 1, allowing for resource allocation based on available counts.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *