GROUP 1 Assignment
GROUP 1 Assignment
1. Introduction.
Deadlocks are a set of blocked processes each holding a resource and waiting to acquire a
resource held by another process in the set.(Operating System Concepts 9th Edition by
Abraham Silberschatz.Pdf - Google Drive, n.d.). It’s a very crucial issue in operating
systems since systems consist of a finite number of resources like CPU cycles, memory
space, I/O devices, files to be distributed among a number of competing threads.
This literature review aims at diving into exploring the causes, methods of handling,
prevention, detection of deadlocks and lastly recovery from deadlocks.
2. Causes of deadlocks.
Deadlock can arise if four conditions hold simultaneously.
Mutual exclusion: only one process at a time can use a resource
Hold and wait: a process holding at least one resource is waiting to acquire
additional resources held by other processes
No preemption: a resource can be released only voluntarily by the process holding
it, after that process has completed its task
Circular wait: there exists a set {P0, P1, …, Pn} of waiting processes such that P0 is
waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P2,
…, Pn–1 is waiting for a resource that is held by Pn, and Pn is waiting for a resource
that is held by P0.
Deadlocks can be described more precisely in terms of a directed graph called a system
resource-allocation graph
Circular Wait – impose a total ordering of all resource types, and require that each process
requests resources in an increasing order of enumeration
5. Deadlock Avoidance
A deadlock avoidance policy grants a resource request only if it can establish that granting
the request cannot lead to a deadlock either immediately or in the future.(Deadlock
Prevention And Avoidance - GeeksforGeeks, n.d.)
The kernel lacks detailed knowledge about future behaviour of processes, so it cannot
accurately predict deadlocks. Therefore, this requires that the operating system be given
additional information in advance concerning which resources a thread will request and use
during its lifetime. With this additional knowledge, the operating system can decide for each
request whether or not the thread should wait.
Simplest and most useful model requires that each process declare the maximum number of
resources of each type that it may need before they are allocated. This is achieved using
Banker’s algorithm.
The Banker’s Algorithm is a resource allocation and deadlock avoidance algorithm that tests
for safety by simulating the allocation for the predetermined maximum possible amounts of
all resources, then makes an “s-state” check to test for possible activities, before deciding
whether allocation should be allowed to continue.(Banker’s Algorithm in Operating System -
GeeksforGeeks, n.d.)
6. Deadlock Detection.
Deadlock detection is a process in computing where the system checks if there are any sets of
processes that are stuck waiting for each other indefinitely, preventing them from moving
forward. (Introduction of Deadlock in Operating System - GeeksforGeeks, n.d.)
Deadlock Detection and Recovery is the mechanism of detecting and resolving deadlocks in
an operating system (Deadlock Prevention And Avoidance - GeeksforGeeks, n.d.)
Detection methods help identify when deadlocks happen, and recovery techniques are used to
resolve these issues and restore system functionality. This ensures that computers and devices
can continue working without interruptions caused by deadlock situations.
The OS periodically checks the system for any deadlock. In case, it finds any of the deadlock
then the OS will recover the system using some recovery techniques.
The main task of the OS is detecting the deadlocks. The OS can detect the deadlocks with the
help of Resource allocation graph. In single instanced resource types, if a cycle is being
formed in the system, then there will definitely be a deadlock. On the other hand, in multiple
instanced resource type graph, detecting a cycle is not just enough. We have to apply the
safety algorithm on the system by converting the resource allocation graph into the allocation
matrix and request matrix.
Wait-For Graph Algorithm
The Wait-For Graph Algorithm is a deadlock detection algorithm used to detect deadlocks in
a system where resources can have multiple instances. The algorithm works by constructing a
Wait-For Graph, which is a directed graph that represents the dependencies between
processes and resources.
To ensure the system never enters a deadlock state, we employ deadlock prevention and
deadlock avoidance. Occasional the system checks for any deadlocks. If found, the
system can either pre-empt the resource or rollback to the safe state.
9. REFERENCES
Banker’s Algorithm in Operating System - GeeksforGeeks. (n.d.). Retrieved October 19,
2024, from https://www.geeksforgeeks.org/bankers-algorithm-in-operating-system-2/
Deadlock Prevention And Avoidance - GeeksforGeeks. (n.d.). Retrieved October 19, 2024,
from https://www.geeksforgeeks.org/deadlock-prevention/
Introduction of Deadlock in Operating System - GeeksforGeeks. (n.d.). Retrieved October 5,
2024, from https://www.geeksforgeeks.org/introduction-of-deadlock-in-operating-
system/
Operating System Concepts 9th Edition by Abraham Silberschatz.pdf - Google Drive. (n.d.).
Retrieved October 5, 2024, from https://drive.google.com/file/d/0B_YRww-
7bRxjMVZibkZ5N01wcE0/preview?resourcekey=0-eMirl5uoYyVldescnTN2AQ