1/8
flashcards made from Preventing Deadlocks slides from week 9
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Deadlock Prevention
• Deadlock avoidance can only be implemented if there is detailed information about future requests, which is not common
• Deadlock prevention can be used in more realistic scenarios
• Assure that at least one of the conditions is never satisfied
– Mutual exclusion
– Hold and wait
– No Preemption
– Circular wait
Attacking Mutual-Exclusion
• If no resource were ever assigned exclusively to a single process, there would never be deadlocks
– Yet, this does not work in practice – how can two processes write on the printer at the same time?
• However, avoiding assigning a resource unless absolutely necessary is a good idea
Attacking Hold-and-Wait
• Preventing processes that hold resources from waiting for more resources, eliminates deadlocks
– Requires all processes to request all resources before starting execution
– Problem: many processes do not know how many resources they need at the start
Attacking No-Preemption
• For resources that are virtualised it is possible to use pre-emption
• Not all fit that category
– For example, records in databases or tables inside the operating system must be locked to be used and therein lies the potential for deadlock.
Attacking Circular Wait Condition (1)
Attacking Circular Wait Condition (2)
Communication Deadlocks
Livelock
Starvation
• If many processes require the same resource, some might never have a chance to use it (starvation), depending on the resource allocation algorithm
• Algorithms like first-come, first-served do not cause starvation