What this operating-systems semaphore question tests
This is a foundational question on synchronization primitives — core building blocks in concurrent systems. It checks whether you understand the formal definition and purpose of a semaphore, rather than just its use in code.
Interviewers ask this to establish whether you have a clear mental model of how processes and threads coordinate access to shared resources. A good answer moves beyond "it's a lock" to explain the underlying abstraction: a counter that threads can increment and decrement, with blocking semantics when the counter reaches zero.
- Atomic operations and mutual exclusion
- Blocking vs. spinning synchronization
- Binary vs. counting semaphores
- The relationship between semaphores and locks/mutexes