Reviewed by Aditya Kumar · Last reviewed 2026-03-24
Semaphore: Count-based sync; P (wait) decrements, blocks if 0; V (signal) increments. Binary (0/1) = mutex. USE: Limit concurrent DB connections, producer-consumer buffers, rate limiting. WHY: Mutex is one-at-a-time; semaphore allows N concurrent....
Semaphore: Count-based sync; P (wait) decrements, blocks if 0; V (signal) increments. Binary (0/1) = mutex. USE: Limit concurrent DB connections, producer-consumer buffers, rate limiting. WHY: Mutex is one-at-a-time; semaphore allows N concurrent. COST: Avoid priority inversion; deadlock risk with multiple sems.
Red Flag: Confusing mutex and semaphore. Pro-Move: 'Connection pool of 10—semaphore(10); P before acquire, V on release; we use timeouts to avoid deadlock.'
According to DataEngPrep.tech, this is one of the most frequently asked General/Other interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.