What is priority inversion in an RTOS, and how would you prevent a low-priority task from blocking a high-priority one on a shared resource?

technical-conceptual · Junior level · software-engineering

What the interviewer is really asking

Tests understanding of a classic RTOS concurrency hazard and the standard mitigation (priority inheritance / using a mutex rather than a binary semaphore for mutual exclusion).

What to say

What to avoid

Example answers

Strong: Priority inversion is when a high-priority task is blocked on a mutex held by a low-priority task, and then a medium-priority task preempts the low one. The high task can't run even though it's the most important, because the resource holder isn't getting CPU. The standard fix is a mutex with priority inheritance: while the low task holds the lock the kernel temporarily raises it to the high task's priority so it finishes and releases quickly. I'd also keep the critical section as short as possible.

Weak: That's when tasks get their priorities mixed up so the wrong one runs. I'd fix it by giving the important task a much higher priority number so the scheduler always picks it first over the others.

Want questions matched to your role? Paste a job title, job description, or CV and get a personalized set, or go Pro to unlock the full bank.