Dealing With Contention hard
What is Priority Inversion in a preemptive multitasking system?
- A When High Priority tasks run faster.
- B When the scheduler crashes.
- C When a Low Priority task holds a shared lock needed by a High Priority task, but the Low Priority task is preempted by a Medium Priority task, effectively making the High Priority task wait for the Medium one.
- D When tasks run in reverse order.
Answer: C. When a Low Priority task holds a shared lock needed by a High Priority task, but the Low Priority task is preempted by a Medium Priority task, effectively making the High Priority task wait for the Medium one.
Solved by 'Priority Inheritance' (boosting the priority of the lock holder to match the waiter).
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- Why is 'Exponential Backoff' preferred over constant intervals for retries?
- What is the primary purpose of a Mutex (Mutual Exclusion) lock?
- Why does adding more threads sometimes *decrease* performance?
- In a Saga, if a Compensating Transaction (Undo) fails repeatedly due to contention, what is the last resort?
- In a database, what happens if Transaction A locks a row and Transaction B tries to modify the same row?
- A database restart causes thousands of application servers to instantly try to reconnect. This crashes the DB again. This is called: