Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Mutex vs Semaphore in RTOS

MediumSecurity & Infrastructure00:00
Practice interviewer
In session
5 left
00:00

Your question is Mutex vs Semaphore in RTOS. Take a moment with it on the right.

Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).

You need to log in / sign up to chat or submit.

Problem

Scenario

You are working on embedded firmware for a battery-powered device running a small RTOS. Multiple tasks share peripherals such as I2C, SPI, and a ring buffer used by an interrupt handler and a worker task, and a recent bug caused intermittent stalls and priority inversion under load. The codebase currently mixes mutexes, binary semaphores, and counting semaphores without a clear rule for when each should be used.

Question

How would you compare a mutex and a semaphore in this embedded context, and when would you choose each? Explain the tradeoffs around ownership, ISR interaction, priority inversion, deadlock risk, and how you would structure synchronization for shared peripherals and task signaling.