Friday, October 8, 1993 Announcement - Working date for midterm: Monday, October 18, 1993 (through chapter 6) - Friday October 15 class will be devoted to Question and Answer as prep. - Instructor will be out of town on 10/18 so you should review material by 10/15 - TA has sent out test data (announced last time) and sample project run. If you don't have email access, see him. ------------------------------------------------------------------------------- Today: Deadlock avoidance and Deadlock detection ------------------------------------------------------------------------------- General idea: require additional information about how resources will be requested. Use this information to determine whether to grant an allocation request or to cause the requesting process to wait. One such approach is used by Dijkstra's Banker's Algorithm *Maximum need* for process declared by each process *safe (resource allocation) state*: some way exists for OS to satisify all potential requests by running processes in some order More formally, there exists a sequence of processes such that for each Pi in the sequence, 1<=i<=n the resources that Pi can still request (i.e., maximum need - current need) can be satisfied by the currently available resources plus the resources held by all the Pj, jPj implies Pi waiting for Pj to release a resource. Essentially remove resource nodes and collapse arcs. Cycle in wait-for graph implies deadlock. Finding cycle in graph is O(n^2) for n processes. ------------------------------------------------------------------------------- Recovery from deadlock Process termination alternatives - abort all deadlocked processes - abort one process at a time until deadlock cycle eliminated. Requires checking for deadlock after terminating each process. Perhaps use "minimum cost" metric to decide which to terminate first. (e.g., process priority, process longevity [long-lived process might be ready to terminate], resource holdings, difference between current resource allocation and maximum, as declared by process, interactive vs batch ...] Resource preemption: successively preempt resources until deadlock cycle is broken - selection of victim similar to above (cost factors); avoid starvation - rollback of process to some consistent state necessary (since it no longer has processes it once had) -------------------------------------------------------------------------------