Struggling With Assignments !!! Stuck on Your Homework?

Let Our Expert Tutors Help You.

Get Personalized Writing Help
from Live Web Tutors

Deadlocks Assignment Help


A deadlock is a situation in which two or more competing actions are waiting for each other to finish, and thus neither ever does. In an operating system, a deadlock is a situation which occurs when a process enters a waiting state because a resource requested by it is being held by another waiting process, which in turn is waiting for another resourceDeadlock is a problem in multiprocessing systems, parallel computing and distributed systems, where software and hardware locks are used to handle shared resources and implement synchronization.


In order for deadlock to occur, four conditions must be true-


Mutual exclusion - Each resource is either currently allocated to exactly one process or it is available.

Hold and Wait - processes currently holding resources can request new resources.

No preemption - Once a process holds a resource, it cannot be taken away by another process.

Circular wait - Each process is waiting to obtain a resource which is held by another process.


Solutions to deadlock


There are several ways to address the problem of deadlock in an operating system.


• Just ignore it and hope it doesn't happen.

• Detection and recovery - if it happens, take action.

• Dynamic avoidance by careful resource allocation. Check to see if a resource can be granted, and if granting it will cause deadlock, don't grant it.

• Prevention.


Ignoring deadlock


In this approach, it is assumed that a deadlock will never occur. This is also an application of the Ostrich algorithm.


Detection


Under deadlock detection, deadlocks are allowed to occur. Then the state of the system is examined to detect that a deadlock has occurred. An algorithm is employed that tracks resource allocation and process states, it rolls back and restarts one or more of the processes in order to remove the detected deadlock


After a deadlock is detected, it can be corrected by using one of the following methods:


1. Process Termination: One or more process involved in the deadlock may be aborted. We can choose to abort all processes involved in the deadlock. This approach has high overheads because after each abortion an algorithm must determine whether the system is still in deadlock


2.Resource Preemption: Resources allocated to various processes may be successively preempted and allocated to other processes until the deadlock is broken.Deadlock avoidance


Another solution is to avoid deadlock by only granting resources if granting them cannot result in a deadlock situation later. This is an unrealistic approach.

Deadlock Prevention Deadlock prevention strategies involve changing the rules so that processes will not make requests that could result in deadlock.



Get Homework Help Right Now!