Tuesday, August 30, 2022

Deadlock in Operating System | Loksewa 2078

 Q. What do you mean by Deadlock? What are the necessary conditions for the deadlock to occur? (2+3+5) marks

answer:

Deadlock is a situation where two or more processes are waiting for each other. When a process requests resources and those resources are not available, the process enters a waiting state. Sometimes, a waiting process is permanently unable to change state because the resources it has requested are held by other waiting processes. This situation is called deadlock. Lets take a real time example, To obtain a voter card, you must provide proof of address, but to obtain proof of address, you must already have a voter card. So it depends on one another. Until any one step is not resolved this deadlock situation exists even in real life.

@missionofficer

Necessary Conditions of Deadlock

There are four different conditions that result in Deadlock. These four conditions are also known as Coffman conditions and these conditions are not mutually exclusive.  They are:

1. Mutual

When this scenario occurs, only one process at a time can hold a resource, during which it cannot be shared with other applications. In addition, this is a critical policy applied by operating systems to prevent conflicts from occurring when two or more processes are using the resource simultaneously, which may result in incomplete data being saved.

Nevertheless, this is a necessary condition for deadlocks to occur. The programs would not have to wait for each other if they could share the same resources.

2. Hold and Wait

A process must be handled at least one resource and waiting to require additional resources that are currently being held by the other processes.

3. No Preemption

It is not possible to forcefully prevent a resource from being included in a process by another process. As an example, if a process P1 is using a resource R, another process P2 cannot forcefully take it. Hence, various scheduling algorithms do not seem to be needed if that's the case. P2 can request and wait for the process P1 to release the resource R, which would be useful for the process P1.

4, Circular  Wait

Circular wait involves processes waiting for each other in a circle. Consequently, no one releases their own resource; everyone waits for each other to release it. Here, everyone is waiting to receive the resource. This is called a circular wait. To reach a deadlock, all four conditions need to be met. If a deadlock occurs, either the operating system needs to perform some work or the system needs to be rebooted.

As soon as the circular wait is broken, the issue will be resolved since each program can then get the resources they need.

Therefore, All four conditions are necessary for deadlock to occur. If any single one is prevented or resolved, the deadlock is resolved.


Send us more question, we will provide the solution.

Thank You! Stay Safe.

@missionofficer


No comments:

Post a Comment

Featured post

Major Challenges for economic development of Nepal | Loksewa old Question Paper 2078

Q. Wha t do you mean by Economic Growth and Economic Development?  What are the main challenges of economic development of Nepal? Give your ...

Popular Posts