Search⌘ K
AI Features

Deadlock Avoidance via Scheduling

Explore deadlock avoidance by understanding how thread scheduling with knowledge of lock acquisition can prevent deadlocks. Learn to analyze thread lock demands and create safe execution schedules that preserve concurrency while ensuring system stability. This lesson guides you through practical examples and highlights the trade-offs in performance and concurrency when employing avoidance strategies like scheduling.

We'll cover the following...

Instead of deadlock prevention, in some scenarios deadlock avoidance is preferable. Avoidance requires some global knowledge of which locks various threads might grab during their execution, and subsequently, schedules said threads in a way as to guarantee no deadlock can occur.

For example, assume we have two processors and four threads that must be scheduled upon them. Assume further we know that Thread 1 (T1) grabs locks L1 and L2 (in some order, at some point during its execution), T2 grabs L1 and L2 ...