Systems and low latency
Thread 1 locks A then B; thread 2 locks B then A.
AppliedMultiple choice
Thread 1 locks A then B; thread 2 locks B then A. Occasionally both hang. What is the standard fix?
- AAdd a short sleep between acquiring the two locks
- BAcquire locks in one global order everywhere
- CUse more threads so that one of them always makes progress
- DReplace the mutexes with spin locks
The worked solution is in Premium
The answer, the full working and the one idea to take away – for this and all 1,322 questions in the bank. Answer it in practice and your working is marked, with a known mistake named when you make one.
Report an issue with this question
Learn the method
Of the kind reported at
More systems and low latency questions
- A producer writes data then sets a flag; a consumer reads the flag then the data.Expert · Premium
- A ring buffer has capacity 1024 and wraps its index with a bit mask instead of a modulo.Foundation · Premium
- Per-thread counters, part 1 of 3Foundation · Premium
- Five per cent of a workload is inherently serial.Applied · Premium
- A system handles 10⁶ messages a second with an average time in system of 5 μs.Applied · Premium
- Messages arrive at 400,000 a second and take 2 μs each to process on one thread.Advanced · Premium