Mutex vs Semaphore | OS Interview | Skill-Lync Resources
Easy Operating Systems Synchronization

What is the difference between a mutex and a semaphore?

Answer

A mutex (mutual exclusion) is a locking mechanism that allows only one thread to access a resource at a time - it has ownership (only the thread that locked can unlock). A semaphore is a signaling mechanism with a counter that allows multiple threads up to a limit - counting semaphore allows N concurrent accesses, binary semaphore acts like mutex but without ownership. Mutex is for exclusive access; semaphores are for resource counting and signaling.

Master These Concepts with IIT Certification
IIT Certified

Master These Concepts with IIT Certification

175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.

Relevant for Roles

Software Engineer Backend Developer Systems Developer