Question 5 OS.

a). Explain in details how the deadlocks differs from starvation?

b). For single unit resources, we can mode resource allocation and requests as a directed graph connecting processes and resources. Draw/sketch a such a graph and explain what it is involved in deadlock detection.

1 answer

a) Deadlocks and starvation are both related to resource allocation in operating systems, but they differ in their nature and implications.

Deadlocks occur when two or more processes are waiting indefinitely for a resource held by another process in a circular chain. This leads to a situation where none of the processes can progress, causing the system to become unresponsive. Deadlocks can be resolved through various methods such as resource preemption, ordering resources, and deadlock avoidance algorithms.

On the other hand, starvation occurs when a process is constantly overlooked in favor of other processes, leading to the process never being able to access the required resource. This can happen due to unfair scheduling algorithms or improper resource allocation strategies. Starvation does not necessarily lead to a system-wide halt like deadlocks, but it can severely impact the performance and efficiency of the system.

In summary, deadlocks involve a specific situation where processes are blocked due to circular dependencies on resources, while starvation refers to a situation where a process is constantly neglected in favor of others.

b) In a system with single unit resources, resource allocation and requests can be modeled as a directed graph connecting processes and resources. Each process is represented as a node, and each resource is represented as an edge connecting the process that currently holds the resource to the process that is requesting it.

The basic idea behind deadlock detection using a directed graph is to look for a cycle in the graph. If a cycle is found, it indicates that a deadlock has occurred, as each process in the cycle is waiting for a resource held by another process in the cycle.

By analyzing the graph and identifying cycles, the system can detect deadlocks and take appropriate actions to resolve them, such as resource preemption or restarting affected processes. The graph also helps in identifying the specific processes and resources involved in the deadlock, making it easier to pinpoint the root cause of the issue.