The document discusses deadlocks in computer systems and various approaches to handling them. It defines deadlock as when a set of processes are blocked waiting for resources held by each other in a cyclic manner. There are four conditions required for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Methods to handle deadlocks include ignoring the problem, preventing deadlocks through design restrictions, avoiding deadlocks by dynamically checking for safety, and detecting and recovering from deadlocks after the fact. The banker's algorithm is presented as an avoidance technique using a resource allocation graph and safety checks.
The document discusses deadlocks in operating systems. It defines a deadlock as a situation where multiple processes are waiting indefinitely for resources held by each other in a cyclic manner. Four necessary conditions for a deadlock to occur are mutual exclusion, hold and wait, no preemption, and circular wait. Methods to handle deadlocks include deadlock prevention by ensuring at least one condition is never satisfied, deadlock avoidance by tracking resource usage to prevent unsafe states, and deadlock detection and recovery by allowing deadlocks to occur and resolving them. The banker's algorithm is presented for deadlock avoidance with multiple resource instances using data structures to track available, allocated, and needed resources.
The document summarizes key topics about deadlocks in operating systems including deadlock characterization, prevention, and avoidance. It defines deadlock as a set of blocked processes where each process is waiting for a resource held by another in the set. Four conditions must be met for deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock prevention methods ensure systems never enter a deadlock state while avoidance uses a safe state algorithm and resource ordering to dynamically prevent unsafe states.
Useful documents for engineering students of CSE, and specially for students of aryabhatta knowledge university, Bihar (A.K.U. Bihar). It covers following topics: System model deadlock characterization, methods for handling deadlocks, deadlock prevention,
deadlock avoidance, deadlock detection, recovery from deadlock
This document outlines the key aspects of deadlocks in operating systems. It defines the necessary conditions for a deadlock to occur as mutual exclusion, hold and wait, no preemption, and circular wait. A resource-allocation graph is used to model resource usage, where a cycle indicates a potential deadlock. Deadlocks can be prevented by avoiding one of the necessary conditions, or can be detected using the graph model to identify cycles. Upon detection, processes may need to be terminated or have resources preempted to recover from the deadlock.
This document discusses deadlocks in computer systems. It defines the four necessary conditions for deadlock and introduces resource allocation graphs to model deadlock states. It describes three main approaches to handling deadlocks: prevention, detection and recovery, and ignoring the problem. The rest of the document focuses on techniques for deadlock prevention, including holding and waiting, no preemption, and circular wait conditions. It also covers deadlock avoidance using safe state models, resource allocation graphs, and Banker's algorithm to determine if a resource request would result in an unsafe state.
Process synchronization ensures systematic sharing of resources among concurrent processes. A race condition occurs when two processes access and modify shared resources without coordination. In a printer spooler example, two processes modify shared variables that point to files to print and available slots, which could result in files being skipped or printed multiple times. The critical section is the part of the program where shared memory is accessed; avoiding race conditions requires no two processes to be in their critical section simultaneously. Deadlocks occur when a set of processes are blocked waiting for resources held by other processes in the set, forming a circular wait. Methods to handle deadlocks include prevention, avoidance, detection, and recovery.
The document describes operating system concepts related to resource allocation and deadlocks. It defines a system model where processes compete for shared resources. A deadlock occurs when a set of processes are blocked waiting for resources held by other processes in the set, forming a circular wait. The document outlines four conditions for deadlock and describes methods to prevent, avoid, detect, and recover from deadlocks using techniques like safe state algorithms, resource ordering, and process termination.
This document discusses deadlocks in computer systems. It begins by defining a deadlock as a state where a set of blocked processes are each holding resources and waiting for resources held by others in a cyclic manner. It then presents methods for handling deadlocks, including prevention, avoidance, and detection and recovery. For avoidance, it describes using a resource allocation graph to model processes and resources, and the banker's algorithm to ensure the system is always in a safe state where deadlocks cannot occur.
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Wakil Kumar
Help to other students on research paper on Deadlock- System model, resource types, deadlock problem, deadlock characterization, methods for deadlock handling,
This document discusses deadlocks in operating systems. It defines deadlock as when a set of blocked processes each hold a resource and wait for a resource held by another process. It then covers methods for handling deadlocks such as prevention, avoidance, detection, and recovery. Prevention ensures deadlock conditions cannot occur. Avoidance allows the system to deny requests that could lead to deadlock. Detection identifies when a deadlock has occurred. Recovery breaks deadlocks by terminating or preempting processes.
The document discusses process synchronization and deadlocks. It introduces race conditions, critical sections, and solutions to synchronize processes like semaphores. Classical problems like the dining philosophers problem and bridge crossing example are presented. Deadlocks are characterized by conditions like mutual exclusion, hold and wait, no preemption and circular wait. Methods to handle deadlocks include prevention through ordering of resource requests and avoidance using resource allocation states.
This document outlines different methods for handling deadlocks in operating systems, including deadlock prevention, avoidance, detection, and recovery. It discusses the four necessary conditions for deadlock and defines a resource-allocation graph model. For deadlock prevention, it describes ways to ensure that the mutual exclusion, hold and wait, no preemption, and circular wait conditions cannot simultaneously hold through protocols like requesting all resources at start, releasing resources before requesting new ones, preempting held resources, and imposing a total ordering of resource types. Deadlock avoidance uses additional process information to decide if a request should wait. Detection identifies deadlocks in the system state, while recovery terminates processes or preempts resources.
This document outlines different methods for handling deadlocks in operating systems, including deadlock prevention, avoidance, detection, and recovery. It discusses the four necessary conditions for deadlock and introduces the concept of a resource-allocation graph. For deadlock prevention, it describes ways to ensure that the conditions of mutual exclusion, hold and wait, no preemption, and circular wait do not all occur simultaneously, such as requiring processes to request all resources upfront or imposing a total ordering of resource types. Deadlock avoidance uses additional information about future resource needs to decide if a request can be granted. Detection and recovery methods are employed if deadlocks are allowed to occur.
Deadlock and memory management -- Operating SystemEktaVaswani2
This document discusses operating system resources, deadlocks, and memory management. It defines system resources as any usable parts of a computer that can be controlled and assigned by the operating system. It describes the four conditions required for a deadlock and methods for detecting, avoiding, and recovering from deadlocks such as terminating processes. It also discusses memory management techniques like paging, swapping, and virtual memory that allow more programs to reside in memory than the physical memory size.
This document describes a course on operating systems with a focus on deadlocks and memory management. It discusses deadlocks in depth, including the necessary conditions for deadlocks, methods for handling them through prevention, avoidance, detection and recovery. For deadlock prevention, it describes how to ensure the hold-and-wait, no preemption and circular wait conditions do not occur. Deadlock avoidance requires knowledge of future resource requests to determine if a process must wait. The document also provides an overview of memory management strategies like swapping, contiguous allocation and paging.
A deadlock occurs when a set of processes are blocked because each process is holding a resource and waiting for another resource held by another process in the set, creating a circular wait. Four necessary conditions must be met for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlocks can be handled through deadlock avoidance, detection and recovery, or prevention. Avoidance methods like Banker's Algorithm use safe state models to prevent deadlocks, while detection algorithms use resource allocation graphs to detect deadlocks. Once detected, deadlocks are recovered through process termination or resource preemption.
This document discusses deadlocks in a multiprogramming system. It defines deadlock as a situation where a set of processes are waiting indefinitely for resources held by each other in a circular chain. Four necessary conditions for deadlock are explained: mutual exclusion, hold and wait, no preemption, and circular wait. Methods for handling deadlocks include prevention, avoidance, detection and recovery. Prevention methods aim to enforce restrictions to ensure at least one condition cannot be met, such as allocating all resources for a process upfront or not allowing processes to hold resources while waiting for others.
Deadlock occurs in a system when multiple processes are waiting indefinitely for resources held by other waiting processes, resulting in no progress. The four conditions required for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock can be avoided by ensuring that at least one of these conditions does not occur through methods like deadlock prevention, deadlock avoidance using safe sequences, and the banker's algorithm.
This document discusses various techniques for handling deadlocks in operating systems, including prevention, avoidance, detection, and recovery. Deadlock prevention methods ensure deadlock conditions cannot occur by restricting resource usage. Deadlock avoidance algorithms dynamically examine the resource allocation state to guarantee the system remains in a safe state. Detection algorithms search for resource allocation cycles to identify deadlocks. Recovery methods terminate or roll back processes involved in deadlocks. The document provides examples to illustrate these deadlock handling techniques.
Deadlock occurs when multiple processes are blocked waiting for resources held by other processes in the set, resulting in no forward progress. There are four conditions required for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock can be handled through prevention, avoidance, detection, and recovery. Prevention ensures one of the four conditions is never satisfied. Avoidance allows resource allocation if it does not lead to an unsafe state. Detection identifies when deadlock occurs. Recovery regains resources by terminating processes or preempting resources.
This document summarizes key concepts related to deadlocks in operating systems. It defines the four necessary conditions for deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. It describes methods for handling deadlocks, including deadlock prevention, avoidance, detection, and recovery. Deadlock prevention techniques aim to ensure that at least one of the necessary conditions does not hold, such as imposing an ordering on how resources can be requested. Deadlock avoidance uses additional information to determine if a request could lead to a deadlocked state. Detection and recovery methods allow deadlocks to occur but provide algorithms for identifying and resolving deadlocked processes.
This document discusses deadlocks in computer systems. It defines the four necessary conditions for deadlock and introduces resource allocation graphs to model deadlock states. It describes three main approaches to handling deadlocks: prevention, detection and recovery, and ignoring the problem. The rest of the document focuses on techniques for deadlock prevention, including holding and waiting, no preemption, and circular wait conditions. It also covers deadlock avoidance using safe state models, resource allocation graphs, and Banker's algorithm to determine if a resource request would result in an unsafe state.
Process synchronization ensures systematic sharing of resources among concurrent processes. A race condition occurs when two processes access and modify shared resources without coordination. In a printer spooler example, two processes modify shared variables that point to files to print and available slots, which could result in files being skipped or printed multiple times. The critical section is the part of the program where shared memory is accessed; avoiding race conditions requires no two processes to be in their critical section simultaneously. Deadlocks occur when a set of processes are blocked waiting for resources held by other processes in the set, forming a circular wait. Methods to handle deadlocks include prevention, avoidance, detection, and recovery.
The document describes operating system concepts related to resource allocation and deadlocks. It defines a system model where processes compete for shared resources. A deadlock occurs when a set of processes are blocked waiting for resources held by other processes in the set, forming a circular wait. The document outlines four conditions for deadlock and describes methods to prevent, avoid, detect, and recover from deadlocks using techniques like safe state algorithms, resource ordering, and process termination.
This document discusses deadlocks in computer systems. It begins by defining a deadlock as a state where a set of blocked processes are each holding resources and waiting for resources held by others in a cyclic manner. It then presents methods for handling deadlocks, including prevention, avoidance, and detection and recovery. For avoidance, it describes using a resource allocation graph to model processes and resources, and the banker's algorithm to ensure the system is always in a safe state where deadlocks cannot occur.
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Wakil Kumar
Help to other students on research paper on Deadlock- System model, resource types, deadlock problem, deadlock characterization, methods for deadlock handling,
This document discusses deadlocks in operating systems. It defines deadlock as when a set of blocked processes each hold a resource and wait for a resource held by another process. It then covers methods for handling deadlocks such as prevention, avoidance, detection, and recovery. Prevention ensures deadlock conditions cannot occur. Avoidance allows the system to deny requests that could lead to deadlock. Detection identifies when a deadlock has occurred. Recovery breaks deadlocks by terminating or preempting processes.
The document discusses process synchronization and deadlocks. It introduces race conditions, critical sections, and solutions to synchronize processes like semaphores. Classical problems like the dining philosophers problem and bridge crossing example are presented. Deadlocks are characterized by conditions like mutual exclusion, hold and wait, no preemption and circular wait. Methods to handle deadlocks include prevention through ordering of resource requests and avoidance using resource allocation states.
This document outlines different methods for handling deadlocks in operating systems, including deadlock prevention, avoidance, detection, and recovery. It discusses the four necessary conditions for deadlock and defines a resource-allocation graph model. For deadlock prevention, it describes ways to ensure that the mutual exclusion, hold and wait, no preemption, and circular wait conditions cannot simultaneously hold through protocols like requesting all resources at start, releasing resources before requesting new ones, preempting held resources, and imposing a total ordering of resource types. Deadlock avoidance uses additional process information to decide if a request should wait. Detection identifies deadlocks in the system state, while recovery terminates processes or preempts resources.
This document outlines different methods for handling deadlocks in operating systems, including deadlock prevention, avoidance, detection, and recovery. It discusses the four necessary conditions for deadlock and introduces the concept of a resource-allocation graph. For deadlock prevention, it describes ways to ensure that the conditions of mutual exclusion, hold and wait, no preemption, and circular wait do not all occur simultaneously, such as requiring processes to request all resources upfront or imposing a total ordering of resource types. Deadlock avoidance uses additional information about future resource needs to decide if a request can be granted. Detection and recovery methods are employed if deadlocks are allowed to occur.
Deadlock and memory management -- Operating SystemEktaVaswani2
This document discusses operating system resources, deadlocks, and memory management. It defines system resources as any usable parts of a computer that can be controlled and assigned by the operating system. It describes the four conditions required for a deadlock and methods for detecting, avoiding, and recovering from deadlocks such as terminating processes. It also discusses memory management techniques like paging, swapping, and virtual memory that allow more programs to reside in memory than the physical memory size.
This document describes a course on operating systems with a focus on deadlocks and memory management. It discusses deadlocks in depth, including the necessary conditions for deadlocks, methods for handling them through prevention, avoidance, detection and recovery. For deadlock prevention, it describes how to ensure the hold-and-wait, no preemption and circular wait conditions do not occur. Deadlock avoidance requires knowledge of future resource requests to determine if a process must wait. The document also provides an overview of memory management strategies like swapping, contiguous allocation and paging.
A deadlock occurs when a set of processes are blocked because each process is holding a resource and waiting for another resource held by another process in the set, creating a circular wait. Four necessary conditions must be met for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlocks can be handled through deadlock avoidance, detection and recovery, or prevention. Avoidance methods like Banker's Algorithm use safe state models to prevent deadlocks, while detection algorithms use resource allocation graphs to detect deadlocks. Once detected, deadlocks are recovered through process termination or resource preemption.
This document discusses deadlocks in a multiprogramming system. It defines deadlock as a situation where a set of processes are waiting indefinitely for resources held by each other in a circular chain. Four necessary conditions for deadlock are explained: mutual exclusion, hold and wait, no preemption, and circular wait. Methods for handling deadlocks include prevention, avoidance, detection and recovery. Prevention methods aim to enforce restrictions to ensure at least one condition cannot be met, such as allocating all resources for a process upfront or not allowing processes to hold resources while waiting for others.
Deadlock occurs in a system when multiple processes are waiting indefinitely for resources held by other waiting processes, resulting in no progress. The four conditions required for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock can be avoided by ensuring that at least one of these conditions does not occur through methods like deadlock prevention, deadlock avoidance using safe sequences, and the banker's algorithm.
This document discusses various techniques for handling deadlocks in operating systems, including prevention, avoidance, detection, and recovery. Deadlock prevention methods ensure deadlock conditions cannot occur by restricting resource usage. Deadlock avoidance algorithms dynamically examine the resource allocation state to guarantee the system remains in a safe state. Detection algorithms search for resource allocation cycles to identify deadlocks. Recovery methods terminate or roll back processes involved in deadlocks. The document provides examples to illustrate these deadlock handling techniques.
Deadlock occurs when multiple processes are blocked waiting for resources held by other processes in the set, resulting in no forward progress. There are four conditions required for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock can be handled through prevention, avoidance, detection, and recovery. Prevention ensures one of the four conditions is never satisfied. Avoidance allows resource allocation if it does not lead to an unsafe state. Detection identifies when deadlock occurs. Recovery regains resources by terminating processes or preempting resources.
This document summarizes key concepts related to deadlocks in operating systems. It defines the four necessary conditions for deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. It describes methods for handling deadlocks, including deadlock prevention, avoidance, detection, and recovery. Deadlock prevention techniques aim to ensure that at least one of the necessary conditions does not hold, such as imposing an ordering on how resources can be requested. Deadlock avoidance uses additional information to determine if a request could lead to a deadlocked state. Detection and recovery methods allow deadlocks to occur but provide algorithms for identifying and resolving deadlocked processes.
object oriented programming using java, second sem BCA,UoMambikavenkatesh2
Constructors are special methods that initialize objects when they are created. They have the same name as the class and do not specify a return type. There are three types of constructors: no-arg, parameterized, and default. Overloaded constructors have the same name but different parameters. The garbage collector deletes unused objects to free up memory. Finalizer methods are called before an object is garbage collected and allow for cleanup.
data structures using C 2 sem BCA univeristy of mysoreambikavenkatesh2
The document discusses reallocating memory using the realloc() function in C. It provides code to allocate memory for an integer array, print the memory addresses, reallocate the array to a larger size, and print the new memory addresses. The memory addresses for the previously allocated blocks do not change after reallocating, but new contiguous blocks are added to increase the array size.
Go to tableau.com to try Tableau for free by clicking "Try Tableau for Free" and starting a free trial. Download and install the Tableau Desktop software, then open it to connect to data, create visualizations on a worksheet, and customize data fields without modifying the original data. The start page provides options to connect to files, servers, or previous data sources to explore your data and begin building visualizations.
The document defines basic concepts about computers and the internet. It discusses that a computer is a general purpose machine that can accept, store, manipulate and generate data. It then covers the history of computers, including important figures like Charles Babbage, Alan Turing, and the development of the Von Neumann architecture. The document also defines basic computer components like hardware, software, CPU, RAM, ROM and input/output devices. It then discusses basics of the internet such as protocols, IP addresses, servers, clients, URLs and how the world wide web works using HTTP. Finally, it covers intranets, extranets, and defines audio and video conferencing.
E-commerce involves commercial transactions conducted over the internet between organizations and individuals. It is a subset of e-business and is defined as digitally enabled commercial transactions. E-commerce is made possible by underlying technologies like the internet, world wide web, and mobile platforms. It has unique features such as ubiquity, global reach, universal standards, richness, interactivity, information density, personalization, customization, and social connectivity through user generated content and social networks.
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia
In the world of technology, Jacob Murphy Australia stands out as a Junior Software Engineer with a passion for innovation. Holding a Bachelor of Science in Computer Science from Columbia University, Jacob's forte lies in software engineering and object-oriented programming. As a Freelance Software Engineer, he excels in optimizing software applications to deliver exceptional user experiences and operational efficiency. Jacob thrives in collaborative environments, actively engaging in design and code reviews to ensure top-notch solutions. With a diverse skill set encompassing Java, C++, Python, and Agile methodologies, Jacob is poised to be a valuable asset to any software development team.
This research is oriented towards exploring mode-wise corridor level travel-time estimation using Machine learning techniques such as Artificial Neural Network (ANN) and Support Vector Machine (SVM). Authors have considered buses (equipped with in-vehicle GPS) as the probe vehicles and attempted to calculate the travel-time of other modes such as cars along a stretch of arterial roads. The proposed study considers various influential factors that affect travel time such as road geometry, traffic parameters, location information from the GPS receiver and other spatiotemporal parameters that affect the travel-time. The study used a segment modeling method for segregating the data based on identified bus stop locations. A k-fold cross-validation technique was used for determining the optimum model parameters to be used in the ANN and SVM models. The developed models were tested on a study corridor of 59.48 km stretch in Mumbai, India. The data for this study were collected for a period of five days (Monday-Friday) during the morning peak period (from 8.00 am to 11.00 am). Evaluation scores such as MAPE (mean absolute percentage error), MAD (mean absolute deviation) and RMSE (root mean square error) were used for testing the performance of the models. The MAPE values for ANN and SVM models are 11.65 and 10.78 respectively. The developed model is further statistically validated using the Kolmogorov-Smirnov test. The results obtained from these tests proved that the proposed model is statistically valid.
The use of huge quantity of natural fine aggregate (NFA) and cement in civil construction work which have given rise to various ecological problems. The industrial waste like Blast furnace slag (GGBFS), fly ash, metakaolin, silica fume can be used as partly replacement for cement and manufactured sand obtained from crusher, was partly used as fine aggregate. In this work, MATLAB software model is developed using neural network toolbox to predict the flexural strength of concrete made by using pozzolanic materials and partly replacing natural fine aggregate (NFA) by Manufactured sand (MS). Flexural strength was experimentally calculated by casting beams specimens and results obtained from experiment were used to develop the artificial neural network (ANN) model. Total 131 results values were used to modeling formation and from that 30% data record was used for testing purpose and 70% data record was used for training purpose. 25 input materials properties were used to find the 28 days flexural strength of concrete obtained from partly replacing cement with pozzolans and partly replacing natural fine aggregate (NFA) by manufactured sand (MS). The results obtained from ANN model provides very strong accuracy to predict flexural strength of concrete obtained from partly replacing cement with pozzolans and natural fine aggregate (NFA) by manufactured sand.
Introduction to ANN, McCulloch Pitts Neuron, Perceptron and its Learning
Algorithm, Sigmoid Neuron, Activation Functions: Tanh, ReLu Multi- layer Perceptron
Model – Introduction, learning parameters: Weight and Bias, Loss function: Mean
Square Error, Back Propagation Learning Convolutional Neural Network, Building
blocks of CNN, Transfer Learning, R-CNN,Auto encoders, LSTM Networks, Recent
Trends in Deep Learning.
Empowering Electric Vehicle Charging Infrastructure with Renewable Energy Int...AI Publications
The escalating energy crisis, heightened environmental awareness and the impacts of climate change have driven global efforts to reduce carbon emissions. A key strategy in this transition is the adoption of green energy technologies particularly for charging electric vehicles (EVs). According to the U.S. Department of Energy, EVs utilize approximately 60% of their input energy during operation, twice the efficiency of conventional fossil fuel vehicles. However, the environmental benefits of EVs are heavily dependent on the source of electricity used for charging. This study examines the potential of renewable energy (RE) as a sustainable alternative for electric vehicle (EV) charging by analyzing several critical dimensions. It explores the current RE sources used in EV infrastructure, highlighting global adoption trends, their advantages, limitations, and the leading nations in this transition. It also evaluates supporting technologies such as energy storage systems, charging technologies, power electronics, and smart grid integration that facilitate RE adoption. The study reviews RE-enabled smart charging strategies implemented across the industry to meet growing global EV energy demands. Finally, it discusses key challenges and prospects associated with grid integration, infrastructure upgrades, standardization, maintenance, cybersecurity, and the optimization of energy resources. This review aims to serve as a foundational reference for stakeholders and researchers seeking to advance the sustainable development of RE based EV charging systems.
This research presents the optimization techniques for reinforced concrete waffle slab design because the EC2 code cannot provide an efficient and optimum design. Waffle slab is mostly used where there is necessity to avoid column interfering the spaces or for a slab with large span or as an aesthetic purpose. Design optimization has been carried out here with MATLAB, using genetic algorithm. The objective function include the overall cost of reinforcement, concrete and formwork while the variables comprise of the depth of the rib including the topping thickness, rib width, and ribs spacing. The optimization constraints are the minimum and maximum areas of steel, flexural moment capacity, shear capacity and the geometry. The optimized cost and slab dimensions are obtained through genetic algorithm in MATLAB. The optimum steel ratio is 2.2% with minimum slab dimensions. The outcomes indicate that the design of reinforced concrete waffle slabs can be effectively carried out using the optimization process of genetic algorithm.
Dear SICPA Team,
Please find attached a document outlining my professional background and experience.
I remain at your disposal should you have any questions or require further information.
Best regards,
Fabien Keller
2. Department of CSE- Data Science
Contents
System model
Deadlock characterization
Methods for handling deadlocks
Deadlock prevention
Deadlock avoidance
Deadlock detection and recovery from deadlock
3. Department of CSE- Data Science
Introduction
Deadlock is a situation where a set of processes are blocked because each process is
holding a resource and waiting for another resource acquired by some other process.
For example, in the below diagram, Process 1 is holding Resource 1 and waiting for
resource 2 which is acquired by process 2, and process 2 is waiting for resource 1.
4. Department of CSE- Data Science
Bridge Crossing Example
Traffic only in one direction
Each section of a bridge can be viewed as a resource
If a deadlock occurs, it can be resolved if one car backs up (preempt resources and
rollback)
5. Department of CSE- Data Science
System Model
System consists of Resource types R1, R2, . . ., Rm – CPU cycles, memory space, I/O
devices
Each resource type Ri has Wi instances.
Each process utilizes a resource as follows:
1. Request. The process requests the resource. If the request cannot be granted
immediately (for example, if the resource is being used by another process), then the
requesting process must wait until it can acquire the resource.
2. Use. The process can operate on the resource (for example, if the resource is a printer,
the process can print on the printer).
3. Release. The process releases the resource.
6. Department of CSE- Data Science
Deadlock Characterization
Deadlock can arise if four conditions hold simultaneously
1. Mutual exclusion: only one process at a time can use a resource
2. Hold and wait: a process holding at least one resource is waiting to acquire
additional resources held by other processes
3. No preemption: a resource can be released only voluntarily by the process holding it,
after that process has completed its task
4. 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.
7. Department of CSE- Data Science
Resource Allocation
Graphical representation of the state of the system.
It contains the information about all the instances of all the resources
A set of vertices V and a set of edges E
V is partitioned into two types:
– P = {P1, P2, …, Pn}, the set consisting of all the processes in the system
– R = {R1, R2, …, Rm}, the set consisting of all resource types in the system
request edge – directed edge Pi Rj
assignment edge – directed edge Rj Pi
9. Department of CSE- Data Science
Resource Allocation Graph Example
One instance of R1
Two instances of R2
One instance of R3
Three instance of R4
P1 holds one instance of R2 and is waiting for
an instance of R1
P2 holds one instance of R1, one instance of
R2, and is waiting for an instance of R3
P3 is holds one instance of R3
10. Department of CSE- Data Science
Resource Allocation Graph with a Deadlock
P1->R1->P2->R3->P3->R2->P1
P2->R3->P3->R2->P2
11. Department of CSE- Data Science
Graph with a Cycle But no Deadlock
P1->R1->P3->R2->P1
12. Department of CSE- Data Science
Basic Facts
If graph contains no cycles -no deadlock
If graph contains a cycle
– if only one instance per resource type, then deadlock
– if several instances per resource type, possibility of deadlock
13. Department of CSE- Data Science
Methods for Handling Deadlocks
Ensure that the system will never enter a deadlock state
‣ To ensure that deadlocks never occur, the system can either use deadlock prevention or a
deadlock-avoidance scheme.
‣ Deadlock prevention provides a set of methods for ensuring that at least one of the
necessary conditions cannot hold.
• Deadlock-avoidance requires that the operating system be given in advance additional
information concerning which resources a process will request and use during its
lifetime. With this additional knowledge, it can decide for each request whether or not
the process should wait.
Allow the system to enter a deadlock state and then recover
‣ The system can provide an algorithm that examines the state of the system to
determine whether a deadlock has occurred and an algorithm to recover from the
deadlock (if a deadlock has indeed occurred).
Ignore the problem and pretend that deadlocks never occur in the system
14. Department of CSE- Data Science
Deadlock Prevention
For a deadlock to occur, each of the four necessary conditions must hold.
By ensuring that at least one of these conditions cannot hold, we can prevent the occurrence
of a deadlock.
1.Mutual Exclusion: not required for sharable resources; must hold for non sharable resources
The mutual-exclusion condition must hold for non sharable resources.
For example, a printer cannot be simultaneously shared by several processes.
Sharable resources, in contrast, do not require mutually exclusive access and thus cannot be
involved in a deadlock.
Read-only files are a good example of a sharable resource. If several processes attempt to
open a read-only file at the same time, they can be granted simultaneous access to the file.
A process never needs to wait for a sharable resource.
In general, however, we cannot prevent deadlocks by denying the mutual-exclusion
condition, because some resources are intrinsically non sharable.
15. Department of CSE- Data Science
2. Hold and Wait
must guarantee that whenever a process requests a resource, it does not hold any other
resources
One protocol that can be used requires each process to request and be allocated all its
resources before it begins execution
An alternative protocol allows a process to request resources only when it has none. A
process may request some resources and use them. Before it can request any additional
resources, however, it must release all the resources that it is currently allocated.
Example: consider a process that copies data from a DVD drive to a file on disk, sorts the
file, and then prints the results to a printer.
‣ If all resources must be requested at the beginning of the process, then the process must
initially request the DVD drive, disk file, and printer. It will hold the printer for its
entire execution, even though it needs the printer only at the end.
16. Department of CSE- Data Science
‣ The second method allows the process to request initially only the DVD drive and disk file. It
copies from the DVD drive to the disk and then releases both the DVD drive and the disk file.
The process must then again request the disk file and the printer. After copying the disk file to
the printer, it releases these two resources and terminates.
Two main disadvantages.
1. Resource utilization may be low, since resources may be allocated but unused for a long
period. In the example given, for instance, we can release the DVD drive and disk file, and
then again request the disk file and printer only if we can be sure that our data will remain
on the disk file. Otherwise, we must request all resources at the beginning for both protocols.
2. Starvation is possible. A process that needs several popular resources may have to wait
indefinitely, because at least one of the resources that it needs is always allocated to some
other process.
17. Department of CSE- Data Science
3. No Preemption
To ensure that this condition does not hold, we can use the following protocol.
‣ If a process that is holding some resources requests another resource that cannot be
immediately allocated to it, then all resources currently being held are released
‣ Preempted resources are added to the list of resources for which the process is waiting
‣ Process will be restarted only when it can regain its old resources, as well as the new
ones that it is requesting
4. Circular Wait
‣ One way to ensure that this condition never holds is to impose a total ordering of all
resource types and to require that each process requests resources in an increasing order
of enumeration.
‣ For example, if the set of resource types R includes tape drives, disk drives, and printers,
then the function F might be defined as follows:
F (tape drive) = 1 F (disk drive) = 5 F (printer) = 12
18. Department of CSE- Data Science
‣ a process that wants to use the tape drive and printer at the same time must first request
the tape drive and then request the printer.
‣ Simply assign each resource (i.e., mutex locks) a unique number.
‣ Resources must be acquired in order.
If:
first_mutex = 1
second_mutex = 5
19. Department of CSE- Data Science
Deadlock Avoidance
Requires that the system has some additional a priori information available
‣ Simplest and most useful model requires that each process declare the maximum
number of resources of each type that it may need
‣ The deadlock-avoidance algorithm dynamically examines the resource-allocation
state to ensure that there can never be a circular-wait condition
‣ Resource-allocation state is defined by the number of available and allocated
resources, and the maximum demands of the processes
20. Department of CSE- Data Science
Safe State
When a process requests an available resource, system must decide if immediate
allocation leaves the system in a safe state.
System is in safe state if there exists a safe sequence of all processes.
Sequence <P1, P2, …, Pn> is safe if for each Pi, the resources that Pi can still request can
be satisfied by currently available resources + resources held by all the Pj, with j<i.
– If Pi resource needs are not immediately available, then Pi can wait until all Pj have
finished.
– When Pj is finished, Pi can obtain needed resources, execute, return allocated
resources, and terminate.
– When Pi terminates, Pi+1 can obtain its needed resources, and so on.
21. Department of CSE- Data Science
Basic Facts
If a system is in safe state no deadlocks
If a system is in unsafe state possibility of deadlock
Avoidance ensure that a system will never enter an unsafe state
Figure : Safe, unsafe, and deadlocked state spaces.
22. Department of CSE- Data Science
To illustrate, we consider a system with twelve magnetic tape drives and three
processes: P0, P1, and P2.
Process P0 requires ten tape drives, process P1 may need as many as four tape
drives, and process P2 may need up to nine tape drives.
Suppose that, at time to, process P0 is holding five tape drives, process P1 is
holding two tape drives, and process P2 is holding two tape drives.
Thus, there are three free tape drives.
Maximum Needs Current Needs
P0 10 5
P1 4 2
P2 9 2
23. Department of CSE- Data Science
At time t0, the system is in a safe state. The sequence <P1, P0, P2> satisfies the safety
condition.
‣ Process P1 can immediately be allocated all its tape drives and then return them (the
system will then have five available tape drives);
‣ Then process P0 can get all its tape drives and return them (the system will then have
ten available tape drives)
‣ Finally process P2 can get all its tape drives and return them (the system will then
have all twelve tape drives available).
A system can go from a safe state to an unsafe state.
24. Department of CSE- Data Science
Resource-Allocation Graph Algorithm
Claim edge Pi Rj indicated that process Pi may request resource Rj; represented
by a dashed line.
Claim edge converts to request edge when a process requests a resource.
When a resource is released by a process, assignment edge reconverts to a claim
edge.
Resources must be claimed a priori in the system.
25. Department of CSE- Data Science
Resource-Allocation Graph For Deadlock Avoidance
Assignment
Edge
Request
Edge
Claim
Edge
Claim
Edge
26. Department of CSE- Data Science
Unsafe State In A Resource-Allocation Graph
27. Department of CSE- Data Science
Bankers Safety Algorithm
The Banker's algorithm is a resource allocation and deadlock avoidance algorithm
developed by Edsger Dijkstra,
Tests for safety by simulating the allocation of predetermined maximum possible amounts
of all resources, and then makes a "s-state" check to test for possible deadlock conditions
for all other pending activities, before deciding whether allocation should be allowed to
continue.
The Banker's algorithm is run by the operating system whenever a process requests
resources
The algorithm avoids deadlock by denying or postponing the request if it determines that
accepting the request could put the system in an unsafe state (one where deadlock could
occur).
28. Department of CSE- Data Science
When a new process enters a system, it must declare the maximum number of instances
of each resource type that it may ever claim; clearly, that number may not exceed the
total number of resources in the system.
Also, when a process gets all its requested resources it must return them in a finite
amount of time.
Data Structures for the Banker’s Algorithm
Let n = number of processes, and m = number of resources types.
1. Available: Vector of length m. If available [j] = k, there are k instances of resource
type Rj available
2. Max: n x m matrix. If Max [i,j] = k, then process Pi may request at most k
instances of resource type Rj
29. Department of CSE- Data Science
3. Allocation: n x m matrix. If Allocation[i,j] = k then Pi is currently allocated k
instances of Rj
4. Need: n x m matrix. If Need[i,j] = k, then Pi may need k more instances of Rj to
complete its task
Need [i,j] = Max[i,j] – Allocation [i,j]
30. Department of CSE- Data Science
Safety Algorithm
1. Let Work and Finish be vectors of length m and n, respectively. Initialize:
Work = Available
Finish [i] = false for i = 0, 1, …, n- 1
2. Find an i such that both:
(a) Finish [i] = false
(b) Needi Work
If no such i exists, go to step 4
3. Work = Work + Allocationi
Finish[i] = true
go to step 2
4. If Finish [i] == true for all i, then the system is in a safe state
31. Department of CSE- Data Science
Resource-Request Algorithm for Process Pi
Requesti = request vector for process Pi. If Requesti [j] = k then process Pi wants k
instances of resource type Rj.
1. If Requesti Needi go to step 2. Otherwise, raise error condition, since process
has exceeded its maximum claim.
2. If Requesti Available, go to step 3. Otherwise Pi must wait, since resources
are not available.
3. Pretend to allocate requested resources to Pi by modifying the state as follows:
Available := Available - Requesti;
Allocationi := Allocationi + Requesti;
Needi := Needi – Requesti;;
- If safe the resources are allocated to Pi.
- If unsafe Pi must wait, and the old resource-allocation state is restored
32. Department of CSE- Data Science
Example of Banker’s Algorithm
5 processes P0 through P4; 3 resource types A (10 instances), B (5 instances), and C (7
instances).
Snapshot at time T0:
Allocation Max Available
A B C A B C A B C
P0 0 1 0 7 5 3 3 3 2
P1 2 0 0 3 2 2
P2 3 0 2 9 0 2
P3 2 1 1 2 2 2
P4 0 0 2 4 3 3
33. Department of CSE- Data Science
The content of the matrix. Need is defined to be Max – Allocation.
Need
A B C
P0 7 4 3
P1 1 2 2
P2 6 0 0
P3 0 1 1
P4 4 3 1
The system is in a safe state since the sequence < P1, P3, P4, P2, P0> satisfies safety
criteria.
34. Department of CSE- Data Science
Check that Request Available (that is, (1,0,2) (3,3,2) true.
Allocation Need Available
A B C A B C A B C
P0 0 1 0 7 4 3 2 3 0
P1 3 0 2 0 2 0
P2 3 0 1 6 0 0
P3 2 1 1 0 1 1
P4 0 0 2 4 3 1
Executing safety algorithm shows that sequence <P1, P3, P4, P0, P2> satisfies safety
requirement.
35. Department of CSE- Data Science
Deadlock Detection
If a system does not employ either a deadlock-prevention or a deadlock avoidance
algorithm, then a deadlock situation may occur.
In this environment, the system may provide:
‣ An algorithm that examines the state of the system to determine whether a
deadlock has occurred
‣ An algorithm to recover from the deadlock
36. Department of CSE- Data Science
Single Instance of Each Resource Type
If all resources have only a single instance, then we can define a deadlock detection
algorithm that uses a variant of the resource-allocation graph, called a wait-for graph.
Resource Allocation Graph: Contains Processes and Resources.
Wait-for-Graph: Contains only Processes after removing the Resources while conversion
from Resource Allocation Graph.
If the Wait-for-Graph contains a cycle then we can say the system is in a Deadlock state
To detect deadlocks, the system needs to maintain the wait-for graph and periodically
invoke an algorithm that searches for a cycle in the graph.
An algorithm to detect a cycle in a graph requires an order of n2
operations, where n is the
number of vertices in the graph.
37. Department of CSE- Data Science
Deadlock Detection Steps
• Step 1: Take the first process (Pi) from the resource allocation graph and check the
path in which it is acquiring resource (Ri), and start a wait-for-graph with that
particular process.
• Step 2: Make a path for the Wait-for-Graph in which there will be no Resource
included from the current process (Pi) to next process (Pj), from that next process (Pj)
find a resource (Rj) that will be acquired by next Process (Pk) which is released from
Process (Pj).
• Step 3: Repeat Step 2 for all the processes.
• Step 4: After completion of all processes, if we find a closed-loop cycle then the
system is in a deadlock state, and deadlock is detected.
38. Department of CSE- Data Science
Step 1: First take Process P1 which is waiting for Resource R1, resource R1 is acquired by
Process P2, Start a Wait-for-Graph for the above Resource Allocation Graph.
39. Department of CSE- Data Science
Step 2: Now we can observe that there is a path from P1 to P2 as P1 is waiting for R1 which
is been acquired by P2. Now the Graph would be after removing resource R1 looks like.
Step 3: From P2 we can observe a path from P2 to P3 as P2 is waiting for R4 which is
acquired by P3. So make a path from P2 to P3 after removing resource R4 looks like.
40. Department of CSE- Data Science
Step 4: From P3 we find a path to P4 as it is waiting for P3 which is acquired by P4. After
removing R3 the graph looks like this.
Step 5: Here we can find Process P4 is waiting for R2 which is acquired by P1. So finally the
Wait-for-Graph is as follows:
41. Department of CSE- Data Science
Step 6: Finally In this Graph, we found a cycle as the Process P4 again came back to the
Process P1 which is the starting point (i.e., it’s a closed-loop). So, According to the Algorithm
if we found a closed loop, then the system is in a deadlock state. So here we can say the
system is in a deadlock state.
42. Department of CSE- Data Science
Solve this using Wait-for-Graph: Deadlock Exist or not
43. Department of CSE- Data Science
Solution
In this Graph, we don’t find a cycle as no
process came back to the starting point (i.e.,
there is no closed loop). So, According to the
Algorithm if we found a closed loop, then the
system is in a deadlock state in this case no
such closed loop; hence system is free from
deadlock and it is in safe state
45. Department of CSE- Data Science
Several Instances of a Resource Type
The wait-for graph scheme is not applicable to a resource-allocation system with multiple
instances of each resource type.
Lets discuss the deadlock detection algorithm that is applicable to such a system.
The algorithm employs data structures that are similar to those used in the banker's
algorithm
‣ Available: A vector of length m indicates the number of available resources of each
type.
‣ Allocation: An n x m matrix defines the number of resources of each type currently
allocated to each process.
‣ Request: An n x m matrix indicates the current request of each process. If Request
[i][j] = k, then process Pi is requesting k more instances of resource type.Rj.
47. Department of CSE- Data Science
Example
• Five processes P0 through P4;three resource types
A (7 instances), B (2 instances), and C (6 instances).
• Snapshot at time T0:
Allocation Request Available
A B C A B C A B C
P0 0 1 0 0 0 0 0 0 0
P1 2 0 0 2 0 2
P2 3 0 3 0 0 0
P3 2 1 1 1 0 0
P4 0 0 2 0 0 2
• Sequence <P0, P2, P3, P1, P4> will result in Finish[i] = true for all i.
48. Department of CSE- Data Science
Example (Cont.)
• P2 requests an additional instance of type C.
Request
A B C
P0 0 0 0
P1 2 0 1
P2 0 0 1
P3 1 0 0
P4 0 0 2
• State of system?
– Can reclaim resources held by process P0, but insufficient resources to fulfill other
processes; requests.
– Deadlock exists, consisting of processes P1, P2, P3, and P4.
49. Department of CSE- Data Science
Detection-Algorithm Usage
When should the deadlock detection be done? Frequently, or infrequently?
The answer may depend on how frequently deadlocks are expected to occur, as well as the
possible consequences of not catching them immediately
There are two obvious approaches, each with trade-offs:
– Do deadlock detection after every resource allocation which cannot be immediately
granted. This has the advantage of detecting the deadlock right away, while the
minimum number of processes are involved in the deadlock
– Do deadlock detection only when there is some clue that a deadlock may have
occurred, such as when CPU utilization reduces to 40% or some other magic number.
50. Department of CSE- Data Science
Recovery from Deadlock
When a detection algorithm determines that a deadlock exists, there are three basic
approaches to recovery from deadlock:
1. Inform the system operator, and allow him/her to take manual intervention
2. Terminate one or more processes involved in the deadlock
3. Preempt resources
51. Department of CSE- Data Science
Process Termination
Two basic approaches, both of which recover resources allocated to terminated processes:
1. Abort all processes involved in the deadlock. This definitely solves the deadlock, but
at the expense of terminating more processes than would be absolutely necessary.
2. Abort process one by one until the deadlock is broken. This is more conservative, but
requires doing deadlock detection after each step.
Aborting a process may not be easy.
‣ If the process was in the midst of updating a file, terminating it will leave that file in an
incorrect state.
‣ if the process was in the midst of printing data on a printer, the system must reset the
printer to a correct state before printing the next job.
52. Department of CSE- Data Science
If the partial termination method is used, then we must determine which deadlocked process
(or processes) should be terminated. This determination is a policy decision, similar to CPU-
scheduling decisions.
Many factors may affect which process is chosen, including:
1. What the priority of the process is
2. How long the process has computed and how much longer the process will compute
before completing its designated task
3. How many and what types of resources the process has used (for example, whether the
resources are simple to preempt)
4. How many more resources the process needs in order to complete
5. How many processes will need to be terminated
6. Whether the process is interactive or batch
53. Department of CSE- Data Science
Resource Preemption
• When preempting resources to relieve deadlock, there are three important issues to be addressed:
1. Selecting a victim - Deciding which resources to preempt from which processes involves
many of the same decision criteria outlined above.
2. Rollback - Ideally one would like to roll back a preempted process to a safe state prior to the
point at which that resource was originally allocated to the process. Unfortunately it can be
difficult or impossible to determine what such a safe state is, and so the only safe rollback is
to roll back all the way back to the beginning. ( I.e. abort the process and make it start over. )
3. Starvation - How do you guarantee that a process won't starve because its resources are
constantly being preempted? One option would be to use a priority system, and increase the
priority of a process every time its resources get preempted. Eventually it should get a high
enough priority that it won't get preempted any more.