2. INTRODUCTION
Deadlocks in computer systems refer to a situation where multiple processes are blocked because each
process is waiting for another process to release a resource it needs. This creates a vicious cycle where
none of the processes can continue executing. Deadlocks can occur in various types of computer systems,
including operating systems, databases, and distributed systems. Deadlock prevention is the process of
avoiding deadlocks in the system by designing the system in such a way that deadlocks cannot occur. This
can be achieved by implementing strict ordering rules for resource allocation, ensuring that processes
only request resources in a specific order. Another way to prevent deadlocks is by implementing a timeout
mechanism, where a process will release its resources after a certain time if it cannot acquire all the
resources it needs. Deadlock avoidance is the process of detecting potential deadlocks before they occur
and taking steps to prevent them. This can be achieved by dynamically allocating resources based on the
current state of the system, ensuring that the resources are always available to the processes that need
them. Another way to avoid deadlocks is by implementing a resource allocation graph, where processes
and resources are represented as nodes and the resource allocation relationship is represented as edges.
The resource allocation graph can be used to detect potential deadlocks and take steps to prevent them.
3. TECHNIQUES TO AVOID DEADLOCKS
1. Deadlock Prevention
2. Deadlock Avoidance
3. Deadlock Detection and Recovery
4. Deadlock Ignorance
4. DEADLOCK PREVENTION
• Deadlock prevention involves avoiding scenarios that can lead to deadlocks.
• One common technique is the use of resource ordering. In this method, resources
are acquired in a specific order to ensure that they are not requested
simultaneously by multiple processes.
• Another technique is the use of time-outs, in which a process will automatically
release a resource if it is not used within a specified time period.
5. DEADLOCK AVOIDANCE
• Deadlock avoidance is a proactive approach that uses algorithms to determine if a
deadlock is about to occur and takes measures to prevent it.
• There are two main approaches to deadlock avoidance:
1. The banker's algorithm: This is a resource-allocation algorithm that ensures that
a deadlock will never occur by keeping track of the resources currently being held by
each process and ensuring that a new resource allocation request can be safely
granted.
2. The wait-for graph: This approach involves constructing a graph that represents
the relationships between processes and resources, and checking the graph for cycles
to determine whether a deadlock is likely to occur. If a cycle is detected, the request for
a new resource allocation is rejected, preventing the deadlock.
6. DEADLOCK DETECTION AND RECOVERY
• Deadlock detection is a reactive approach that involves periodically checking for
deadlocks in the system. If a deadlock is detected, the system takes measures to
resolve the deadlock.
• There are two main approaches to deadlock detection and recovery:
1. Resource allocation graph: This approach involves constructing a graph that
represents the relationships between processes and resources, and checking the
graph for cycles to determine whether a deadlock has occurred. If a cycle is
detected, one of the processes involved in the deadlock is terminated to break
the cycle and allow the other processes to continue.
2. Wait-for timeout: This approach involves setting a timeout on a process
waiting for a resource. If the process takes too long to obtain the resource, it is
terminated, breaking the deadlock.
7. DEADLOCK IGNORANCE
• Deadlock ignorance is a technique used in computer science to handle deadlocks
in a
multitasking operating system, where the system simply ignores the existence of
deadlocks.
• This technique assumes that deadlocks will eventually resolve themselves, either
through the release of resources by one of the processes involved or through the
termination of one of the processes.
• The main advantage of deadlock ignorance is that it is the simplest approach to
handling deadlocks, as it requires no additional code or algorithms to detect or
recover from deadlocks.
• However, it also has several disadvantages, such as reduced system performance
and the possibility of a process remaining deadlocked indefinitely.
8. CONCLUSION
• In conclusion, deadlocks are a common problem in multitasking operating
systems, and various techniques have been developed to handle them.
• Deadlock prevention involves avoiding situations that could lead to a
deadlock, deadlock avoidance involves checking for potential conflicts before
allocating resources, deadlock detection and recovery involves periodically
checking for deadlocks and recovering from them by aborting one of the
processes involved, and deadlock ignorance involves simply ignoring the
existence of Deadlocks.
• Each of these techniques has its own advantages and disadvantages, and the
best approach depends on the specific requirements of the system.
In computer systems, deadlocks occur when multiple processes become blocked as each process waits for another to release a resource it requires. This creates a cycle where none of the processes can continue to function. Deadlocks can arise in various computer systems such as operating systems, databases, and distributed systems.
To avoid deadlocks, the system can be designed in such a way that they cannot happen. This can be accomplished by implementing strict rules for allocating resources, which ensure processes only request resources in a set order. Another way to prevent deadlocks is by adding a timeout mechanism, where a process releases its resources after a certain period if it is unable to obtain the necessary resources.
Deadlock avoidance, on the other hand, involves identifying potential deadlocks before they occur and taking steps to prevent them. This can be achieved through the dynamic allocation of resources based on the current state of the system, ensuring that resources are always available to the processes that require them. A resource allocation graph can also be used to detect and prevent deadlocks by representing processes and resources as nodes and the resource allocation relationship as edges. Both deadlock prevention and avoidance are crucial for maintaining the stability and performance of computer systems. Deadlocks can lead to data corruption, system crashes, and decreased performance, and by implementing these techniques, the likelihood of deadlocks can be reduced and the system can continue to operate efficiently and reliably.
In computer systems, deadlocks occur when multiple processes become blocked as each process waits for another to release a resource it requires. This creates a cycle where none of the processes can continue to function. Deadlocks can arise in various computer systems such as operating systems, databases, and distributed systems. To avoid deadlocks, the system can be designed in such a way that they cannot happen. This can be accomplished by implementing strict rules for allocating resources, which ensure processes only request resources in a set order. Another way to prevent deadlocks is by adding a timeout mechanism, where a process releases its resources after a certain period if it is unable to obtain the necessary resources. Deadlock avoidance, on the other hand, involves identifying potential deadlocks before they occur and taking steps to prevent them. This can be achieved through the dynamic allocation of resources based on the current state of the system, ensuring that resources are always available to the processes that require them. A resource allocation graph can also be used to detect and prevent deadlocks by representing processes and resources as nodes and the resource allocation relationship as edges. Both deadlock prevention and avoidance are crucial for maintaining the stability and performance of computer systems. Deadlocks can lead to data corruption, system crashes, and decreased performance, and by implementing these techniques, the likelihood of deadlocks can be reduced and the system can continue to operate efficiently and reliably.