Deadlock Prevention of the process.pptx

jaijsr12345 13 views 11 slides Sep 13, 2024
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

Deadlock Prevention of the process.pptx


Slide Content

Name: M . Jaya Sai Roll No : 238R1A12P2 Branch : IT-D Subject : Operating Systems Topic: Deadlock Prevention

Dead Lock Definition: A deadlock Happens when a process or thread can't proceed because another process is holding a resource it needs. Example: All trains are stopped, waiting for another to go, though none of them move.

Deadlock Prevention Deadlock can be prevented by preventing atleast one of the four required conditions: Mutual Exclusion Hold and wait No Preemption Circular Wait

Mutual Exclusion Mutual exclusion means that multiple processes can’t use the same resource at the same time. However, while this is reasonable, it resulting in a deadlock. There will be no process waiting for several processes at the same time. Shared resources such as read-only files do not lead to deadlock. Spooling Technique: It stands for Simultaneous Peripheral Operations Online. Spooling is used for devices like the printer, mouse and keyboard

Continues… Spooling Procedure: Memory is connected to a printer. We can keep all the jobs stored in all processes with assistance of this memory. The printer then collects all of the jobs and prints each one in an FCFS manner. No process will have to wait for the printer. Finally, the printer collects the outputs when they have been created. Using Spooling we can prevent mutual exclusion but Spooling cannot be used for all the resources.

Hold and wait Hold and wait is a condition in which a process is holding one resource while simultaneously waiting for another resource that is being held by another process. The process can’t continue till it gets all the required resouces . Resource 1 is allocated to Process 2 Resource 1 is allocated to Process 2 Resource 1 is allocated to Process 2 Process 1 is waiting for Resource 1 and holding Resource 2 and Resource 3 Process 2 is waiting for Resource 2 and holding Resource 1.

Continues… There are two ways to eliminate hold and wait: By eliminating wait: The process specifies the resources it requires in advance so that it does not have to wait for allocation after execution starts. 2. By eliminating hold: The process has to release all resources it is currently holding before making a new request. The problem with this approach is: Practically not possible. It’s not possible to know in advance which resources will be required , so waiting can’t be prevented.

If a process is holding some resources and waiting for other resources, then it should release all previously held resources and put a new request for the required resources again. The process can resume once it has all the required resources. For example:   If a process has resources R1, R2, and R3 and it is waiting for resource R4, then it has to release R1, R2, and R3 and put a new request of all resources again. 2.If a process P1 is waiting for some resource, and there is another process P2 that is holding that resource and is blocked waiting for some other resource. Then the resource is taken from P2 and allocated to P1. This way process P2 is preempted and it requests again for its required resources to resume the task. The above approaches are possible for resources whose states are easily restored and saved, such as memory and registers. Challenges: Practically not possible. Putting requests for all resources again is inefficient and time-consuming . No preemption Preemption is temporarily interrupting an executing task and later resuming it. There are 2 ways to eliminate this condition by pre-emption:

Circular wait In Circular wait, two or more processes wait for resources in an circular order. To eliminate circular wait, we assign a priority to each resource. A process can only request resources in increasing order of priority. In the example, process P3 is requesting resource R1, which has a number lower than resource R3 which is already allocated to process P3. So this request is invalid and cannot be made, as R1 is already allocated to process P1. Challenges: It is difficult to assign a relative priority to resources, as one resource can be prioritized differently by different processes.

Conclusion Deadlock can be prevented by eliminating any of the four necessary conditions. Mutual exclusion, hold and wait , no preemption cannot be done practically. Circular wait can be feasible eliminate by assigning a priority to each resource. The request is granted if the process requests a resource of higher priority than the resource it currently holds.

Thank you
Tags