What is a deadlock? When there is a cycle in the wait-for graph Which is a bipartite graph of resources and processes An arc from a resource to a process means the resource is held by the process An arc from a process to a resource means the process is waiting for a resource If there is more than one copy of a resource, there is a generalization of the wait-for graph. Solutions to deadlock Tolorate them OK if it's not to often and hurts nothing vital. Make resources sharable Example: We don't wait for the printer, we share the print queue. Never have one All Requests at the Begining stratagy No waiting while holding strategy Requests in a particular order strategy Every program must obey the order. ALL of them. Any failed request releases all held resources strategy Bankers algorithm Each process must have an upper limit on requests O.S. keeps track, make sure to stay in the "safe state region" Use Timeouts Setting a good timeout can be tough What do you want to do when a timeout occurs? Break it if you have it Keep track of the graph, fix something when a cycle forms Remove one resource from a process But how do you handle errors? How does the process ever survive and work Kill a process Which one Destroy a resource Waaaaa?