Deadlock Prevention — Concept Check
Questions on Deadlock Prevention. Deadlock prevention eliminates deadlock by ensuring at least one of the four Coffman conditions can never hold in the system.
Questions in this quiz
7 questions on Deadlock Prevention — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.Two threads each hold one lock and request the other. What deadlock prevention strategy can solve this?
- AUse more threads to handle the locks
- BAllow threads to hold locks indefinitely
- CIncrease the timeout for lock acquisition
- DImplement lock ordering to prevent circular wait
2.A thread uses tryLock() with a timeout but fails to acquire a lock. What happens next?
- AThe thread continues holding its current locks
- BThe thread releases any held locks and retries
- CThe thread waits indefinitely for the lock
- DThe thread terminates immediately
3.In Java, how does lock ordering prevent deadlocks?
- ABy allowing threads to hold multiple locks
- BBy increasing the number of available locks
- CBy ensuring locks are acquired in a consistent order
- DBy making all locks shareable
4.A developer claims that using tryLock() with timeout guarantees no deadlocks. Why is this incorrect?
- AIt enforces a global lock order, which is impractical
- BIt makes locks shareable, which is not always possible
- CIt only breaks hold-and-wait, not other conditions
- DIt requires all resources to be preemptible
5.What is a downside of using lock ordering for deadlock prevention?
- AIt makes locks shareable, reducing security
- BIt can lead to poor resource utilization
- CIt allows threads to hold resources indefinitely
- DIt requires locks to be preemptible
6.A system uses tryLock() with timeout but experiences starvation. What might be the cause?
- AThreads hold locks indefinitely
- BThreads frequently give up locks due to timeouts
- CLocks are acquired in a consistent order
- DAll resources are made shareable
7.Why might lock ordering be preferred over tryLock() with timeout in some systems?
- AIt allows indefinite resource holding
- BIt provides a simpler reasoning model
- CIt makes locks shareable
- DIt eliminates the need for timeouts