Thread A holds lock 1 and waits for lock 2, while thread B holds lock 2 and waits for lock 1. What happened?
- A race that fixes itself
- A waiting cycle, so a deadlock
- One slow lock and nothing more
Which set lists all four things a deadlock needs?
- One holder, hold and wait, no take-back, a cycle
- Two threads, two locks, two cores, two crashes
- A timeout, a retry, a slow disk, a big file
A deadlock can happen even when one of the four conditions is missing.
Circle one: True False
Every thread now takes lock 1 before lock 2. What happens to the waiting cycle?
- It cannot form
- It forms twice as fast
- It moves inside lock 2
In a wait-for graph, which way should an arrow point?
- From the lock to the thread that wants it
- From each thread to itself
- From the waiting thread to the lock holder
Which change removes the no take-back condition?
- Add a third lock to the program
- Let the system reclaim a held lock and hand it back later
- Make both threads sleep a little longer
Sam draws arrows from each lock to the thread waiting for it, finds no loop, and says the program is safe. What is wrong?
- Two threads can never deadlock
- Cycles only matter with three or more locks
- His arrows point the wrong way, so a real cycle stays hidden
All functions take locks in the order 1, 2, 3 except one function that takes 3 then 1. What is the smallest fix?
- Remove lock 2 from the whole program
- Change that one function to take 1 before 3
- Add a timeout to every lock