Information Technology Reference
In-Depth Information
P0
Figure6.6: Graph representation of the state of a deadlocked Dining Philoso-
phers system. Circles represent threads, boxes represent resources, an arrow
from a box/resource to a circle/thread represents anownedbyrelationship
and an arrow from a circle/thread to a box/resource represents awaitingfor
relationship.
chopsticks, which may, for example, allow threads 2 and 3 to eat and release
their chopsticks which would allow threads 4 and 5 to eat.
Although the system shown in Figure 6.7 is not currently deadlocked, it is
still subject to deadlock. For example, if philosopher 1 returns two chopsticks,
philosopher 5 grabs one, and philosopher 1 grabs the other, then the system
would deadlock.
6.2.2
Preventing deadlock
Preventing deadlock can be challenging. For example, consider a system with 3
resources|A, B, and C|and two threads that access them. Thread 1 acquires
A then C then B and thread 2 acquires B then C then A. The following sequence
can lead to deadlock:
 
Search WWH ::




Custom Search