Presentation is loading. Please wait.

Presentation is loading. Please wait.

Deadlock avoidance Deadlock detection Resource Allocation Graphs

Similar presentations


Presentation on theme: "Deadlock avoidance Deadlock detection Resource Allocation Graphs"— Presentation transcript:

1 Deadlock avoidance Deadlock detection Resource Allocation Graphs
DEadlocks Deadlock avoidance Deadlock detection Resource Allocation Graphs

2 Resource Tables

3 Deadlock Definition A deadlock is a situation in which two or more competing actions are each waiting for the other to finish, and thus neither ever does. P P2 P(R1) P(R2) P(R2) P(R1) CS CS V(R2) V(R1) V(R1) V(R2)

4 Deadlock 4 necessary conditions
Mutual Exclusion – Processes claim exclusive control of the resources they require Wait For – processes hold resources already allocated to them while waiting for additional resources No Pre-emption – resources cannot be removed from the process using them until it is used to completion Circular Wait – A circular chain of processes exist in which each process holds one or more resources that are requested by the next process in the chain.

5 Deadlock avoidance Denying Mutex
An Operating System that does not allow mutual exclusion. Problem: This would of course, never have any processes go into a deadlock state, but it’s silly to not allow any resource get exclusive access of a resource. Imagine you want to print a file but you can’t get exclusive access to the printer. You start printing your file, and at the same time another person prints a file. The files would get printed together…on the same paper.

6 Deadlock avoidance Deny Wait For Havender’s 1st strategy
A process get all of it’s resources or none of them. Semaphores can be used. Problems: Must get everything before starting even if it is not needed at the moment Must know in advance, all the resources needed throughout the process.

7 Deadlock avoidance Deny Wait For Havender’s 2nd Strategy
If a process is denied a resource, then it gives up all presently acquired resources. Problem: Could take a long time (possible forever) for a process to run if it keep getting some resources and then gives them up over and over again.

8 Deadlock avoidance Denying No Preemption
Allow the OS to take resources held by processes and give them to processes needing them. Problem: How does the OS decide which processes to take from and which to give to? The gathering of resources will have to restart during processing and may restart infinite times (starvation).

9 Deadlock avoidance Denying Circular Wait
Sequentially number all resources in the entire system. When a process is acquiring resources, the must follow the protocol of obtaining the resources in sequential order. Problem: Forced to acquire resources not needed for a while to maintain order. All programmers must know the order of resources

10 Resource Pool A collection of identical resources Ex)
A room full of printers Computer Storage (on the stack or heap)

11 Dijkstra’s Banker’s Algorithm
Total common resources is 8

12 Bankers Algo - 2 Resource Pools shared

13 RAG – Resource Allocation graph


Download ppt "Deadlock avoidance Deadlock detection Resource Allocation Graphs"

Similar presentations


Ads by Google