1 / 11

deadlock handling

Introduction<br>Deadlock handling in Windows vs Linux<br>Deadlock detection <br>deadlock prevention<br>deadlock handling<br>

Rutba
Télécharger la présentation

deadlock handling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Deadlock handling in windows vs Linux

  2. What is deadlock? • A deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by another process. • For Example: Process 1 is waiting for R1 Resource & Process 2 is waiting for Resource R2. • So both are dependent on resources so they cannot complete their work. So deadlock will occur. R1 Assigned to waiting for P2 P1 Assigned to waiting for R2

  3. A real-life example of deadlock

  4. Difference b/w deadlock and starvation

  5. Conditions for deadlock • Mutual exclusion • Hold and wait • No preemption • Circular wait

  6. Deadlock prevention • Mutual Exclusion: Mutual exclusion says that a resource can only be held by one process at a time. If another process is demanding the same resource it has to wait. • For example, A printer can’t print documents for two users at the same time. • Hold and wait: Hold and wait to arise when a process holds some resources and is waiting for some other resources that are being held by some other waiting process. To avoid this the process can acquire all the resources it needs before it starts execution. • For example: if the process needs 10 resources at a particular time. We can provide R1, R2, R3, and R4. after performing the jobs on these resources the process needs to release these resources and then the other resources provided to the process. In this way, we can avoid hold and wait conditions.

  7. Deadlock prevention • No preemption: In no preemption, a process can’t forcefully take the resource of another process. But if we find some resource due to which deadlock is happening then we can forcefully preempt that resource from the process that is holding that resource. By doing so we can remove the deadlock.\ • For example: if a process P1 is using a resource and a high-priority process P2 requests for the resource, process P1 is stopped and the resources are allocated to P2. • Circular wait: The circular wait is a condition in which the first process is waiting for the resource held by the second process and second the process is waiting for the resource held by the third process and so on. At last, the last process is waiting for the resource held by the first process. So every process is waiting for each other to release the resource. • For example: if the process P1 and P2, requires resource R1 and R2, then initially, both the process will demand the resource R1 and only one of them will get resource R1 at that time and the other process have to wait for its turn.

  8. Deadlock handling Methods • Deadlock Avoidance: In the deadlock avoidance technique, we try to avoid deadlock to happen in our system. • The system wants to be in a safe state always. So, the system maintains a set of data and using that data it decide whether a new request should be accepted or not. • If the system is going into bad state by taking that request, the system will simply ignore that request. • If a request is made for a resource then that request should be only be approved if the resulting of the system is safe.

  9. 2:Detection and recovery • In this approach, the CPU assumes that at some point in time, a deadlock will happen in the system and after that, the CPU will apply some recovery technique to get rid of that deadlock. • The resource allocation graph is used to detect the deadlock in a system. • For recovery, the CPU may forcefully take the resource allocated to some process and give it to the high priority or system process.

  10. Deadlock ignorance • In most systems, deadlock happens rarely. So in this method, the operating system assumes that deadlock never occurs. It simply ignores the deadlock. • This is the most widely used method of deadlock handling. • If you want performance your system should simply ignore the deadlock. • If you are dealing with very important data and you don’t want to lose that if deadlock happens then you should definitely go for deadlock prevention.

  11. Thank You

More Related