All problems in NP can be reduced to another problem in the NP-complete class, and all problem in NP-complete can be reduced to each other 79
If you can prove that any NP-complete , then all NP problems are in problem is in P P! (More motivation: you also win $1M) 80
If you can prove that P ≠ NP , we can stop looking for fast solutions to many hard problems (Motivation: you still win $1M) 81
input decision algorithm yes no A decision problem 82
resources available request & allocations, running programs Will the system deadlock? yes no Deadlock prevention 83
description of a program and its inputs Will the system halt (or run forever)? yes no The halting problem 84
E.g., write the function: half(f) → bool - return true if f will halt - return false otherwise 85
def halt(f): # your code here halt(loop_forever) # => False def loop_forever() while True: pass halt(just_return) # => True def just_return(): return True 86
def gotcha(): if halt(gotcha): loop_forever halt(gotcha) else: just_return !@#$%^&*!!!! 87
Yes Does this program halt? No 88
Proof by contradiction: the halting problem is undecidable 89
Generally speaking, deadlock prediction can be reduced to the halting problem 90
I.e., determining if a system is deadlocked is, in general, provably impossible !!! 91
Deadlock Detection & Recovery 92
Basic approach: cycle detection 93
E.g., Tarjan’s strongly connected components algorithm; O(|V|+|E|) 94
Need only run on mutex resources and “involved” processes …still, would be nice to reduce the size of the resource allocation graph 95
Actual resources involved are unimportant —only care about relationships between processes 96
Resource Allocation Graph P 2 P 1 P 2 P 2 P 2 97
“Wait-for” Graph P 2 P 1 P 2 P 2 P 2 98
P 2 P 2 P 1 P 2 P 2 P 1 P 2 P 2 P 2 P 2 Substantial optimization! 99
…but not very useful when we have multi- instance resources (false positives are likely) 100
Recommend
More recommend