Deadlocks
A deadlock situation can occur in a computer system. Let’s take the following example. Assume two processes A, B need printer and a scanner to carry out a specific task. At the beginning process A grants the printer and start its processing and process B grants the scanner and start its processing. At the middle of the process, process A requests the scanner and process B requests the printer. But none of the requests will be granted as the requesting resource is already obtained by another process. Due to this reason, process A, B will be blocked and will remain as it is forever. This situation is called a deadlock.
Processes can request and grant two types of resources: Preempt-able and Nonprofitable. A preempt-able resource can be taken away from the process owning it with no side effects. Memory is an example for preempt-able resource. A nonprofitable resource cannot be taken away from its current owner without causing the computation to fail. According to Coffman et al. (1971) four conditions should be there to hold a deadlock situation in the computer environment.
Mutual Exclusion: Each resource is either currently assigned to exactly 1 process or is available
Hold & Wait: Process currently holding resources granted earlier can request new resource
No Preemption: Resources previously granted cannot be forcibly taken away from a process. They must be explicitly released by the process holding them.
Circular Wait: There must be a circular chain of 2 or more processes waiting for a resource, held by the next member of the chain
Four types of strategies will be used to handle deadlock situation.
- Just ignore the problem altogether: In this method it will just ignore the problem as nothing has happened to the system.
- Detection & recovery: This method will not prevent deadlocks from the systems, instead it lets them occur. Then it tries to detect it and takes some actions to recover the system.
- Dynamic avoidance by careful resource allocation: from this method it will allocate resources among the processes in such away that a deadlock will not occur within the system.
- Prevention: as four conditions need to be fulfilled to occur a deadlock, preventive methods will be taken to make sure even one of the condition will not be fulfilled in the computer system.


Post a Comment