Deadlocks can be addressed through four main strategies: detection and recovery, avoidance, and prevention. Prevention ensures that at least one of the four conditions for deadlock never occurs, such as by assigning a numeric order to resources and requiring processes request them in that order to avoid circular waits.
This document discusses different strategies for handling deadlocks in operating systems, including prevention, avoidance, detection, and recovery. Prevention methods aim to ensure that one of the four necessary conditions for deadlock does not occur. Avoidance allows all conditions but detects unsafe states and stops requests that could lead to deadlock. Detection identifies when a deadlock has occurred. Recovery methods regain resources by terminating processes or preempting resources to break cycles in resource allocation graphs.
The document discusses input and output in computer systems. It describes three main techniques for transferring data between the CPU and I/O devices: programmed I/O, interrupt-driven I/O, and direct memory access (DMA). Programmed I/O involves the CPU continuously polling I/O devices, interrupt-driven I/O uses interrupts to signal the CPU when data is ready, and DMA allows high-speed transfer of data directly between memory and I/O devices without CPU involvement.
1.Programs reside in the memory & usually get these through the I/P unit.
2. Execution of the program starts when the PC is set to point at the first instruction of the program.
3. Contents of PC are transferred to MAR and a Read Control Signal is sent to the memory.
4. After the time required to access the memory elapses, the address word is read out of the memory and loaded into the MDR.
5. Now contents of MDR are transferred to the IR & now the instruction is ready to be decoded and executed.
6. If the instruction involves an operation by the ALU, it is necessary to obtain the required operands.
7. An operand in the memory is fetched by sending its address to MAR & Initiating a read cycle.
When the operand has been read from the memory
to the MDR, it is transferred from MDR to the ALU.
After one or two such repeated cycles, the ALU
can perform the desired operation.
10. If the result of this operation is to be stored in the memory, the result is sent to MDR.
11. Address of location where the result is stored is sent to MAR & a write cycle is initiated.
12. The contents of PC are incremented so that PC points to the next instruction that is to be executed.
1.Programs reside in the memory & usually get these through the I/P unit.
2. Execution of the program starts when the PC is set to point at the first instruction of the program.
3. Contents of PC are transferred to MAR and a Read Control Signal is sent to the memory.
4. After the time required to access the memory elapses, the address word is read out of the memory and loaded into the MDR.
5. Now contents of MDR are transferred to the IR & now the instruction is ready to be decoded and executed.
6. If the instruction involves an operation by the ALU, it is necessary to obtain the required operands.
7. An operand in the memory is fetched by sending its address to MAR & Initiating a read cycle.
When the operand has been read from the memory
to the MDR, it is transferred from MDR to the ALU.
After one or two such repeated cycles, the ALU
can perform the desired operation.
10. If the result of this operation is to be stored in the memory, the result is sent to MDR.
11. Address of location where the result is stored is sent to MAR & a write cycle is initiated.
12. The contents of PC are incremented so that PC points to the next instruction that is to be executed.
1.Programs reside in the memory & usually get these through the I/P unit.
2. Execution of the program starts when the PC is set to point at the first instruction of the program.
3. Contents of PC are transferred to MAR and a Read Control Signal is sent to the memory.
4. After the time required to access the memory elapses, the address word is read out of the memory and loaded into the MDR.
5. Now contents of MDR are transferred to the IR & now the instruction is ready to be decoded and executed.
6. If the instruction involves an operation by the ALU
The document discusses deadlocks in operating systems. It defines the four conditions for deadlock - mutual exclusion, hold and wait, no preemption, and circular wait. It explains resource allocation graphs and how they can be used to detect deadlocks. The document also covers deadlock prevention methods like mutual exclusion, holding and waiting, preemption, and imposing a total ordering of resources. It describes Banker's algorithm for deadlock prevention and detection with multiple instances of resources. Finally, it discusses different approaches for deadlock recovery like process termination and resource preemption.
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURYअनिकेत चौधरी
This document discusses deadlock detection in distributed systems. It defines deadlock as when a set of processes are permanently blocked waiting for resources held by each other. There are four conditions for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock can be detected using centralized, hierarchical, or distributed approaches. Goldman's distributed algorithm avoids maintaining a continuous wait-for graph by exchanging blocked process lists to detect cycles that indicate deadlocks.
The document discusses deadlocks in operating systems. It defines deadlock and describes the four conditions required for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Methods for handling deadlocks include prevention, avoidance, detection, and recovery. Prevention ensures at least one deadlock condition does not occur. Avoidance uses a resource allocation graph and banker's algorithm to ensure the system never enters an unsafe state. Detection finds deadlocks and recovery releases processes to break deadlocks.
The document discusses deadlocks in operating systems. It defines deadlocks and explains the four necessary conditions for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. It then describes different strategies for handling deadlocks, including prevention, avoidance, detection, and recovery.
The document discusses deadlocks in operating systems. It defines deadlock as when a process waits for a resource held by another waiting process, forming a circular chain of processes waiting for each other. It characterizes deadlock by the conditions of mutual exclusion, hold and wait, no preemption, and circular wait. The document outlines strategies to handle deadlocks through prevention, avoidance, and detection and recovery. It describes resource allocation graphs to model deadlocks and the conditions for deadlocks using AND and OR resource allocation. Finally, it discusses different techniques for deadlock prevention, detection, and recovery in a system.
This document discusses different strategies for handling deadlocks in operating systems, including prevention, avoidance, detection, and recovery. Prevention methods aim to ensure that one of the four necessary conditions for deadlock does not occur. Avoidance allows all conditions but detects unsafe states and stops requests that could lead to deadlock. Detection identifies when a deadlock has occurred. Recovery methods regain resources by terminating processes or preempting resources to break cycles in resource allocation graphs.
The document discusses input and output in computer systems. It describes three main techniques for transferring data between the CPU and I/O devices: programmed I/O, interrupt-driven I/O, and direct memory access (DMA). Programmed I/O involves the CPU continuously polling I/O devices, interrupt-driven I/O uses interrupts to signal the CPU when data is ready, and DMA allows high-speed transfer of data directly between memory and I/O devices without CPU involvement.
1.Programs reside in the memory & usually get these through the I/P unit.
2. Execution of the program starts when the PC is set to point at the first instruction of the program.
3. Contents of PC are transferred to MAR and a Read Control Signal is sent to the memory.
4. After the time required to access the memory elapses, the address word is read out of the memory and loaded into the MDR.
5. Now contents of MDR are transferred to the IR & now the instruction is ready to be decoded and executed.
6. If the instruction involves an operation by the ALU, it is necessary to obtain the required operands.
7. An operand in the memory is fetched by sending its address to MAR & Initiating a read cycle.
When the operand has been read from the memory
to the MDR, it is transferred from MDR to the ALU.
After one or two such repeated cycles, the ALU
can perform the desired operation.
10. If the result of this operation is to be stored in the memory, the result is sent to MDR.
11. Address of location where the result is stored is sent to MAR & a write cycle is initiated.
12. The contents of PC are incremented so that PC points to the next instruction that is to be executed.
1.Programs reside in the memory & usually get these through the I/P unit.
2. Execution of the program starts when the PC is set to point at the first instruction of the program.
3. Contents of PC are transferred to MAR and a Read Control Signal is sent to the memory.
4. After the time required to access the memory elapses, the address word is read out of the memory and loaded into the MDR.
5. Now contents of MDR are transferred to the IR & now the instruction is ready to be decoded and executed.
6. If the instruction involves an operation by the ALU, it is necessary to obtain the required operands.
7. An operand in the memory is fetched by sending its address to MAR & Initiating a read cycle.
When the operand has been read from the memory
to the MDR, it is transferred from MDR to the ALU.
After one or two such repeated cycles, the ALU
can perform the desired operation.
10. If the result of this operation is to be stored in the memory, the result is sent to MDR.
11. Address of location where the result is stored is sent to MAR & a write cycle is initiated.
12. The contents of PC are incremented so that PC points to the next instruction that is to be executed.
1.Programs reside in the memory & usually get these through the I/P unit.
2. Execution of the program starts when the PC is set to point at the first instruction of the program.
3. Contents of PC are transferred to MAR and a Read Control Signal is sent to the memory.
4. After the time required to access the memory elapses, the address word is read out of the memory and loaded into the MDR.
5. Now contents of MDR are transferred to the IR & now the instruction is ready to be decoded and executed.
6. If the instruction involves an operation by the ALU
The document discusses deadlocks in operating systems. It defines the four conditions for deadlock - mutual exclusion, hold and wait, no preemption, and circular wait. It explains resource allocation graphs and how they can be used to detect deadlocks. The document also covers deadlock prevention methods like mutual exclusion, holding and waiting, preemption, and imposing a total ordering of resources. It describes Banker's algorithm for deadlock prevention and detection with multiple instances of resources. Finally, it discusses different approaches for deadlock recovery like process termination and resource preemption.
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURYअनिकेत चौधरी
This document discusses deadlock detection in distributed systems. It defines deadlock as when a set of processes are permanently blocked waiting for resources held by each other. There are four conditions for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock can be detected using centralized, hierarchical, or distributed approaches. Goldman's distributed algorithm avoids maintaining a continuous wait-for graph by exchanging blocked process lists to detect cycles that indicate deadlocks.
The document discusses deadlocks in operating systems. It defines deadlock and describes the four conditions required for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Methods for handling deadlocks include prevention, avoidance, detection, and recovery. Prevention ensures at least one deadlock condition does not occur. Avoidance uses a resource allocation graph and banker's algorithm to ensure the system never enters an unsafe state. Detection finds deadlocks and recovery releases processes to break deadlocks.
The document discusses deadlocks in operating systems. It defines deadlocks and explains the four necessary conditions for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. It then describes different strategies for handling deadlocks, including prevention, avoidance, detection, and recovery.
The document discusses deadlocks in operating systems. It defines deadlock as when a process waits for a resource held by another waiting process, forming a circular chain of processes waiting for each other. It characterizes deadlock by the conditions of mutual exclusion, hold and wait, no preemption, and circular wait. The document outlines strategies to handle deadlocks through prevention, avoidance, and detection and recovery. It describes resource allocation graphs to model deadlocks and the conditions for deadlocks using AND and OR resource allocation. Finally, it discusses different techniques for deadlock prevention, detection, and recovery in a system.
Interrupts allow external events to suspend and later resume processes running on a computer. They improve processor utilization by allowing the operating system to interrupt running processes to respond to external events like user input or I/O device completion. There are different types of interrupts including program-generated, timer, I/O, and hardware failure interrupts. When an interrupt occurs, the CPU saves its context and executes an interrupt handling routine that calls the appropriate interrupt service routine to handle the interrupt before resuming the original process.
The document discusses various topics related to graphs:
- It defines directed and undirected graphs, paths, connected graphs, trees, degree, isomorphic graphs, cut sets, and labeled graphs.
- Key aspects include paths being sequences of vertices with edges connecting them, connected graphs having paths between all vertex pairs, trees being connected and acyclic graphs, and isomorphic graphs having the same structure.
- It also covers graph concepts such as degrees measuring incident edges, cut sets separating graphs, and labeling providing additional data to graphs' vertices or edges.
Two Phase Commit is a protocol that ensures transactions are either fully committed or aborted across multiple database sites. It uses a coordinator node that initiates a prepare phase where other nodes log transaction details and agree/disagree to commit. If all agree, the coordinator initiates a commit phase where nodes commit and acknowledge. This guarantees consistency if a node fails before completion.
Operating system 23 process synchronizationVaibhav Khanna
Processes can execute concurrently
May be interrupted at any time, partially completing execution
Concurrent access to shared data may result in data inconsistency
Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes
Illustration of the problem:Suppose that we wanted to provide a solution to the consumer-producer problem that fills all the buffers. We can do so by having an integer counter that keeps track of the number of full buffers. Initially, counter is set to 0. It is incremented by the producer after it produces a new buffer and is decremented by the consumer after it consumes a buffer
This document discusses problem solving as a state space search. It covers defining the problem as a state space, production systems, search space control strategies, heuristic search techniques like best-first search and branch-and-bound search, problem reduction, constraint satisfaction, and means-ends analysis. It uses chess and a water jug problem to illustrate representing problems as state spaces and defining the rules and operators to solve them through searching the problem space.
instruction format and addressing modesRamaPrabha24
This document discusses computer instruction types and addressing modes in microprocessors. It begins by defining an instruction as a command that tells the microprocessor to perform a task on data. Instructions are made up of opcodes and operands. Instructions are classified by word size into one-byte, two-byte, and three-byte instructions. The document then explains the five addressing modes used in the 8085 microprocessor: immediate, register, direct, indirect, and implicit. Each addressing mode specifies how the operand or data is addressed in memory for an instruction.
Quicksort is a divide and conquer sorting algorithm that works by partitioning an array around a pivot value. It then recursively sorts the sub-arrays on each side. The key steps are: 1) Choose a pivot element to split the array into left and right halves, with all elements on the left being less than the pivot and all on the right being greater; 2) Recursively quicksort the left and right halves; 3) Combine the now-sorted left and right halves into a fully sorted array. The example demonstrates quicksorting an array of 6 elements by repeatedly partitioning around a pivot until the entire array is sorted.
UNIT IV FILE SYSTEMS AND I/O SYSTEMS 9
Mass Storage system – Overview of Mass Storage Structure, Disk Structure, Disk Scheduling and Management, swap space management; File-System Interface – File concept, Access methods, Directory Structure, Directory organization, File system mounting, File Sharing and Protection; File System Implementation- File System Structure, Directory implementation, Allocation Methods, Free Space Management, Efficiency and Performance, Recovery; I/O Systems – I/O Hardware, Application I/O interface, Kernel I/O subsystem, Streams, Performance.
Deadlock avoidance methods analyze resource allocation to determine if granting a request would lead to an unsafe state where deadlock could occur. A deadlock happens when multiple processes are waiting indefinitely for resources held by each other in a cyclic dependency. To prevent deadlock, an operating system must have information on current resource availability and allocations, as well as future resource needs. The system only grants requests that will lead to a safe state where there are enough resources for all remaining processes and deadlock is not possible.
1) A semaphore consists of a counter, a waiting list, and wait() and signal() methods. Wait() decrements the counter and blocks if it becomes negative, while signal() increments the counter and resumes a blocked process if the counter becomes positive.
2) The dining philosophers problem is solved using semaphores to lock access to shared chopsticks, with one philosopher designated as a "weirdo" to avoid deadlock by acquiring locks in a different order.
3) The producer-consumer problem uses three semaphores - one to limit buffer size, one for empty slots, and one for locks - to coordinate producers adding to a bounded buffer
The document discusses interrupts in the 8085 microprocessor. It describes the concept of interrupts, where a peripheral device sends a signal to the CPU requesting attention. When an interrupt occurs, the CPU stops its current process and executes an interrupt service routine. There are three main types of interrupts - external, internal, and software interrupts. External interrupts are initiated by external devices, internal interrupts occur due to program errors, and software interrupts are initiated by executing an instruction. The document provides details on how interrupts are handled, including the interrupt acknowledge process, interrupt priorities, and methods for servicing multiple interrupts.
FellowBuddy.com is an innovative platform that brings students together to share notes, exam papers, study guides, project reports and presentation for upcoming exams.
We connect Students who have an understanding of course material with Students who need help.
Benefits:-
# Students can catch up on notes they missed because of an absence.
# Underachievers can find peer developed notes that break down lecture and study material in a way that they can understand
# Students can earn better grades, save time and study effectively
Our Vision & Mission – Simplifying Students Life
Our Belief – “The great breakthrough in your life comes when you realize it, that you can learn anything you need to learn; to accomplish any goal that you have set for yourself. This means there are no limits on what you can be, have or do.”
Like Us - https://www.facebook.com/FellowBuddycom
A magnetic disk uses a magnetization process to read and write data stored in tracks and sectors on a circular platter coated with a magnetic material. Common examples are hard disks, floppy disks, and zip disks. Modern hard disks use glass substrates, multiple platters, and multiple read/write heads to improve storage capacity and reliability. Data is organized into concentric tracks divided into sectors for efficient reading and writing as the disk rotates.
The Deadlock Problem
System Model
Deadlock Characterization
Methods for Handling Deadlocks
Deadlock Prevention
Deadlock Avoidance
Deadlock Detection
Recovery from Deadlock
Basic Computer Organization and Design
.....................................................................
The basic computer design represents all of the major concepts in CPU design without overwhelming students with the complexity of a modern commercial CPU.
This document describes a course on Theory of Computation. It provides information on the course objectives, which are to understand language hierarchies, construct automata for patterns, design context-free grammars, understand Turing machines and their capabilities, and understand undecidable and NP problems. It outlines 5 units that will be covered: automata fundamentals, regular expressions and languages, context-free grammar and languages, properties of context-free languages, and undecidability. It also provides the course outcomes and lists reference textbooks. The document then begins describing some key concepts from Unit 1, including formal proofs, additional proof forms, inductive proofs, and an introduction to finite automata.
Infix to Prefix (Conversion, Evaluation, Code)Ahmed Khateeb
The document summarizes an assignment on converting infix to prefix notation, evaluating infix expressions, and providing pseudocode to perform the conversion. It includes an example infix expression converted to prefix notation, evaluates the expression to verify the conversion is correct, and provides pseudocode that uses a stack to pop operators and operands off an infix string into a prefix notation string.
This document discusses deadlocks in operating systems. It defines a deadlock as a set of blocked processes that are each holding a resource and waiting for a resource held by another process. Four conditions must be met for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlocks can be modeled using directed resource allocation graphs. Methods for handling deadlocks include prevention, avoidance, detection, and recovery.
A document about deadlocks in operating systems is summarized as follows:
1. A deadlock occurs when a set of processes form a circular chain where each process is waiting for a resource held by the next process in the chain. The four conditions for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait.
2. Deadlocks can be modeled using a resource allocation graph where processes and resources are vertices and edges represent resource requests. A cycle in the graph indicates a potential deadlock.
3. Methods for handling deadlocks include prevention, avoidance, and detection/recovery. Prevention ensures deadlock conditions cannot occur while avoidance allows the system to dynamically verify new allocations will not
Interrupts allow external events to suspend and later resume processes running on a computer. They improve processor utilization by allowing the operating system to interrupt running processes to respond to external events like user input or I/O device completion. There are different types of interrupts including program-generated, timer, I/O, and hardware failure interrupts. When an interrupt occurs, the CPU saves its context and executes an interrupt handling routine that calls the appropriate interrupt service routine to handle the interrupt before resuming the original process.
The document discusses various topics related to graphs:
- It defines directed and undirected graphs, paths, connected graphs, trees, degree, isomorphic graphs, cut sets, and labeled graphs.
- Key aspects include paths being sequences of vertices with edges connecting them, connected graphs having paths between all vertex pairs, trees being connected and acyclic graphs, and isomorphic graphs having the same structure.
- It also covers graph concepts such as degrees measuring incident edges, cut sets separating graphs, and labeling providing additional data to graphs' vertices or edges.
Two Phase Commit is a protocol that ensures transactions are either fully committed or aborted across multiple database sites. It uses a coordinator node that initiates a prepare phase where other nodes log transaction details and agree/disagree to commit. If all agree, the coordinator initiates a commit phase where nodes commit and acknowledge. This guarantees consistency if a node fails before completion.
Operating system 23 process synchronizationVaibhav Khanna
Processes can execute concurrently
May be interrupted at any time, partially completing execution
Concurrent access to shared data may result in data inconsistency
Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes
Illustration of the problem:Suppose that we wanted to provide a solution to the consumer-producer problem that fills all the buffers. We can do so by having an integer counter that keeps track of the number of full buffers. Initially, counter is set to 0. It is incremented by the producer after it produces a new buffer and is decremented by the consumer after it consumes a buffer
This document discusses problem solving as a state space search. It covers defining the problem as a state space, production systems, search space control strategies, heuristic search techniques like best-first search and branch-and-bound search, problem reduction, constraint satisfaction, and means-ends analysis. It uses chess and a water jug problem to illustrate representing problems as state spaces and defining the rules and operators to solve them through searching the problem space.
instruction format and addressing modesRamaPrabha24
This document discusses computer instruction types and addressing modes in microprocessors. It begins by defining an instruction as a command that tells the microprocessor to perform a task on data. Instructions are made up of opcodes and operands. Instructions are classified by word size into one-byte, two-byte, and three-byte instructions. The document then explains the five addressing modes used in the 8085 microprocessor: immediate, register, direct, indirect, and implicit. Each addressing mode specifies how the operand or data is addressed in memory for an instruction.
Quicksort is a divide and conquer sorting algorithm that works by partitioning an array around a pivot value. It then recursively sorts the sub-arrays on each side. The key steps are: 1) Choose a pivot element to split the array into left and right halves, with all elements on the left being less than the pivot and all on the right being greater; 2) Recursively quicksort the left and right halves; 3) Combine the now-sorted left and right halves into a fully sorted array. The example demonstrates quicksorting an array of 6 elements by repeatedly partitioning around a pivot until the entire array is sorted.
UNIT IV FILE SYSTEMS AND I/O SYSTEMS 9
Mass Storage system – Overview of Mass Storage Structure, Disk Structure, Disk Scheduling and Management, swap space management; File-System Interface – File concept, Access methods, Directory Structure, Directory organization, File system mounting, File Sharing and Protection; File System Implementation- File System Structure, Directory implementation, Allocation Methods, Free Space Management, Efficiency and Performance, Recovery; I/O Systems – I/O Hardware, Application I/O interface, Kernel I/O subsystem, Streams, Performance.
Deadlock avoidance methods analyze resource allocation to determine if granting a request would lead to an unsafe state where deadlock could occur. A deadlock happens when multiple processes are waiting indefinitely for resources held by each other in a cyclic dependency. To prevent deadlock, an operating system must have information on current resource availability and allocations, as well as future resource needs. The system only grants requests that will lead to a safe state where there are enough resources for all remaining processes and deadlock is not possible.
1) A semaphore consists of a counter, a waiting list, and wait() and signal() methods. Wait() decrements the counter and blocks if it becomes negative, while signal() increments the counter and resumes a blocked process if the counter becomes positive.
2) The dining philosophers problem is solved using semaphores to lock access to shared chopsticks, with one philosopher designated as a "weirdo" to avoid deadlock by acquiring locks in a different order.
3) The producer-consumer problem uses three semaphores - one to limit buffer size, one for empty slots, and one for locks - to coordinate producers adding to a bounded buffer
The document discusses interrupts in the 8085 microprocessor. It describes the concept of interrupts, where a peripheral device sends a signal to the CPU requesting attention. When an interrupt occurs, the CPU stops its current process and executes an interrupt service routine. There are three main types of interrupts - external, internal, and software interrupts. External interrupts are initiated by external devices, internal interrupts occur due to program errors, and software interrupts are initiated by executing an instruction. The document provides details on how interrupts are handled, including the interrupt acknowledge process, interrupt priorities, and methods for servicing multiple interrupts.
FellowBuddy.com is an innovative platform that brings students together to share notes, exam papers, study guides, project reports and presentation for upcoming exams.
We connect Students who have an understanding of course material with Students who need help.
Benefits:-
# Students can catch up on notes they missed because of an absence.
# Underachievers can find peer developed notes that break down lecture and study material in a way that they can understand
# Students can earn better grades, save time and study effectively
Our Vision & Mission – Simplifying Students Life
Our Belief – “The great breakthrough in your life comes when you realize it, that you can learn anything you need to learn; to accomplish any goal that you have set for yourself. This means there are no limits on what you can be, have or do.”
Like Us - https://www.facebook.com/FellowBuddycom
A magnetic disk uses a magnetization process to read and write data stored in tracks and sectors on a circular platter coated with a magnetic material. Common examples are hard disks, floppy disks, and zip disks. Modern hard disks use glass substrates, multiple platters, and multiple read/write heads to improve storage capacity and reliability. Data is organized into concentric tracks divided into sectors for efficient reading and writing as the disk rotates.
The Deadlock Problem
System Model
Deadlock Characterization
Methods for Handling Deadlocks
Deadlock Prevention
Deadlock Avoidance
Deadlock Detection
Recovery from Deadlock
Basic Computer Organization and Design
.....................................................................
The basic computer design represents all of the major concepts in CPU design without overwhelming students with the complexity of a modern commercial CPU.
This document describes a course on Theory of Computation. It provides information on the course objectives, which are to understand language hierarchies, construct automata for patterns, design context-free grammars, understand Turing machines and their capabilities, and understand undecidable and NP problems. It outlines 5 units that will be covered: automata fundamentals, regular expressions and languages, context-free grammar and languages, properties of context-free languages, and undecidability. It also provides the course outcomes and lists reference textbooks. The document then begins describing some key concepts from Unit 1, including formal proofs, additional proof forms, inductive proofs, and an introduction to finite automata.
Infix to Prefix (Conversion, Evaluation, Code)Ahmed Khateeb
The document summarizes an assignment on converting infix to prefix notation, evaluating infix expressions, and providing pseudocode to perform the conversion. It includes an example infix expression converted to prefix notation, evaluates the expression to verify the conversion is correct, and provides pseudocode that uses a stack to pop operators and operands off an infix string into a prefix notation string.
This document discusses deadlocks in operating systems. It defines a deadlock as a set of blocked processes that are each holding a resource and waiting for a resource held by another process. Four conditions must be met for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlocks can be modeled using directed resource allocation graphs. Methods for handling deadlocks include prevention, avoidance, detection, and recovery.
A document about deadlocks in operating systems is summarized as follows:
1. A deadlock occurs when a set of processes form a circular chain where each process is waiting for a resource held by the next process in the chain. The four conditions for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait.
2. Deadlocks can be modeled using a resource allocation graph where processes and resources are vertices and edges represent resource requests. A cycle in the graph indicates a potential deadlock.
3. Methods for handling deadlocks include prevention, avoidance, and detection/recovery. Prevention ensures deadlock conditions cannot occur while avoidance allows the system to dynamically verify new allocations will not
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.
Shivangi submitted a document on deadlocks to Tapas Sangiri. The 3-sentence summary is:
The document discusses different aspects of deadlocks including definitions, characteristics, methods for handling them such as prevention, avoidance and recovery. Prevention methods aim to ensure a deadlock never occurs by restricting resource allocation in different ways. Avoidance algorithms analyze the resource allocation graph to determine if a system is in a safe state to avoid deadlocks.
The document discusses deadlock in computer systems. It defines deadlock and lists necessary conditions for deadlock including mutual exclusion, hold and wait, no preemption, and circular wait. It also discusses strategies for dealing with deadlock such as detection, recovery, and prevention/avoidance. The resource allocation graph (RAG) model is introduced as a way to represent system states and detect deadlock. Algorithms like Banker's algorithm aim to avoid deadlock by ensuring safe allocation of resources.
This document discusses deadlocks in operating systems. A deadlock occurs when a set of processes are blocked waiting for resources held by each other in a cyclic manner. Four conditions must be met for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. The document outlines strategies for detecting and avoiding deadlocks such as deadlock detection algorithms, safe state models like the Banker's Algorithm, and techniques for preventing the four deadlock conditions.
Distributed deadlock occurs when processes are blocked while waiting for resources held by other processes in a distributed system without a central coordinator. There are four conditions for deadlock: mutual exclusion, hold and wait, non-preemption, and circular wait. Deadlock can be addressed by ignoring it, detecting and resolving occurrences, preventing conditions through constraints, or avoiding it through careful resource allocation. Detection methods include centralized coordination of resource graphs or distributed probe messages to identify resource waiting cycles. Prevention strategies impose timestamp or age-based priority to resource requests to eliminate cycles.
This document discusses the basic concepts of computer architecture and organization. It describes the components of a basic computer including the CPU, memory, and I/O. It explains instruction formats, addressing modes, and the operation of a hardwired control unit. The control unit uses a sequence counter, instruction register, and decoders to generate control signals for instruction fetch, decode, and execution cycles. Interrupts are handled through an interrupt service routine stored in memory.
The document discusses deadlocks that can occur in a multiprocessing system where multiple processes compete for limited resources. A deadlock occurs when a process is waiting for a resource held by another waiting process, resulting in a circular wait. The document outlines the four conditions required for deadlock and describes methods to prevent deadlocks, including imposing a total ordering of resource requests and avoiding holding resources while waiting for additional resources.
A microprogrammed control unit stores control signals for executing instructions in a control memory rather than using dedicated logic. It has four main components: 1) a control memory that stores microinstructions specifying microoperations, 2) a control address register that selects microinstructions, 3) a sequencer that generates the next address, and 4) a pipeline register that holds the selected microinstruction. Microprograms are sequences of microinstructions that are executed to carry out machine-level instructions. Microinstructions can implement conditional branching to alter the control flow.
The document discusses memory management in operating systems. It covers key concepts like logical versus physical addresses, binding logical addresses to physical addresses, and different approaches to allocating memory like contiguous allocation. It also discusses dynamic storage allocation using a buddy system to merge adjacent free spaces, as well as compaction techniques to reduce external fragmentation by moving free memory blocks together. Memory management aims to efficiently share physical memory between processes using mechanisms like partitioning memory and enforcing protection boundaries.
The document provides an introduction to PHP, including:
- PHP is a scripting language originally designed for web pages and runs on most operating systems.
- PHP syntax is quite easy if familiar with C-type languages, and it is designed to output to browsers but can also create CLI apps.
- Variables, constants, naming conventions, data types, and basic control structures like if/else, while loops and foreach loops are discussed.
- Combining PHP with XHTML is covered, recommending using functions and an object-oriented approach.
- User input via forms is mentioned, linking to a resource on processing forms with PHP.
This document discusses deadlocks, which occur when multiple processes are blocked waiting for resources held by other processes in the system, creating a circular wait. It presents four conditions necessary for deadlock and strategies to prevent or avoid deadlocks, including deadlock detection and recovery, and preventing one of the four conditions through methods like restricting resource allocation or ordering resource requests. The document also covers other related issues like two-phase locking and non-resource deadlocks.
Deadlock occurs when multiple processes are waiting for resources held by other processes in the set, resulting in a cyclic wait. There are three main approaches to dealing with deadlock: prevention, avoidance, and detection/recovery. Prevention methods deny one of the necessary conditions for deadlock. Avoidance methods allocate resources in a way that guarantees safe allocation. Detection methods allow deadlock to occur but use resource graphs and reducibility to detect cycles and recover by killing processes or preempting resources. The Banker's Algorithm uses resource allocation tables to determine safe states for avoidance.
A deadlock in OS is a situation in which more than one process is blocked because it is holding a resource and also requires some resource that is acquired by some other process
A deadlock in OS is a situation in which more than one process is blocked because it is holding a resource and also requires some resource that is acquired by some other process. The four necessary conditions for a deadlock situation to occur are mutual exclusion, hold and wait, no preemption and circular
A deadlock in OS is a situation in which more than one process is blocked because it is holding a resource and also requires some resource that is acquired by some other process
This document summarizes principles of deadlock and concurrency mechanisms in operating systems. It discusses deadlock prevention, avoidance, detection and integrated strategies. The dining philosophers problem is presented as an example. Concurrency mechanisms in UNIX, Linux, Solaris and Windows are also summarized, including pipes, messages, shared memory, semaphores, signals, atomic operations, spinlocks, mutex locks, condition variables, and wait functions.
This document discusses different strategies for handling deadlocks in operating systems. It describes the four necessary conditions for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. It then explains three general methods for handling deadlocks: prevention, avoidance, and detection with recovery. Prevention ensures a deadlock never occurs by not allowing one of the four conditions. Avoidance allows all conditions but detects unsafe states and avoids them. Detection knows when a deadlock occurs, while recovery regains locked resources.
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 objectives of Deadlocks in Operating Systems are:
- To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks
- To present a number of different methods for preventing or avoiding deadlocks in a computer system
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.
Mutual Exclusion: One or more than one resource are non-sharable (Only one process can use at a time)
This document discusses deadlocks in operating systems. It defines deadlock as a situation where a set of processes are blocked waiting for resources held by each other in a circular chain. The four necessary conditions for deadlock are discussed: mutual exclusion, hold and wait, no preemption, and circular wait. Methods for handling deadlocks include prevention, detection, recovery, and avoidance. Prevention removes one of the necessary conditions. Detection identifies when a deadlock occurs. Recovery breaks existing deadlocks through preemption, rollback, or killing processes. Avoidance anticipates potential deadlocks through algorithms like the Banker's algorithm.
This document discusses deadlocks and techniques for handling them. It begins by defining the four necessary conditions for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. It then describes three approaches to handling deadlocks: prevention, avoidance, and detection and recovery. Prevention aims to ensure one of the four conditions never holds. Avoidance uses more information to determine if a request could lead to a deadlock. Detection and recovery allows deadlocks but detects and recovers from them after the fact. The document provides examples of different prevention techniques like limiting resource types that can be held, ordering resource types, and preemption. It also explains the banker's algorithm for deadlock avoidance.
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.
The document discusses various issues related to deadlocks including:
1) The four conditions required for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait.
2) Approaches to handling deadlocks such as detection and recovery, avoidance through careful allocation, and prevention by eliminating one of the four conditions.
3) Specific algorithms for deadlock detection, avoidance, and prevention including the banker's algorithm and various graph-based approaches.
This document discusses different approaches to handling deadlocks in operating systems. It begins by defining deadlocks and providing examples. It then describes four conditions required for deadlock to occur. Various methods for handling deadlocks are discussed, including prevention, avoidance, detection, and recovery. Prevention methods aim to restrict system states that could lead to deadlocks. Avoidance methods dynamically allocate resources to ensure the system cannot reach an unsafe state. Detection methods identify deadlocks after they occur, while recovery rolls back processes or terminates them. A combined approach uses elements of multiple methods.
The objectives of Deadlocks in Operating Systems are:
- To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks
- To present a number of different methods for preventing or avoiding deadlocks in a computer system
OS - Unit 3 Deadlock (Bankers Algorithm).pptxGovindJha93
Here is the solution to the Bankers Algorithm example 3:
A) The content of the Need matrix will be:
Process | A | B | C
P0 | 3 | 1 | 3
P1 | 2 | 4 | 2
P2 | 7 | 4 | 5
P3 | 8 | 4 | 6
P4 | 8 | 5 | 5
B) The system is not in a safe state. The available resources (3, 3, 2) are not sufficient to fulfill the need of process P2 (7, 4, 5).
C) If process P1 requests one more instance of resource A and two instances of resource C, the request can be granted as
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
Physiology and chemistry of skin and pigmentation, hairs, scalp, lips and nail, Cleansing cream, Lotions, Face powders, Face packs, Lipsticks, Bath products, soaps and baby product,
Preparation and standardization of the following : Tonic, Bleaches, Dentifrices and Mouth washes & Tooth Pastes, Cosmetics for Nails.
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Thinking of getting a dog? Be aware that breeds like Pit Bulls, Rottweilers, and German Shepherds can be loyal and dangerous. Proper training and socialization are crucial to preventing aggressive behaviors. Ensure safety by understanding their needs and always supervising interactions. Stay safe, and enjoy your furry friends!
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
How to Build a Module in Odoo 17 Using the Scaffold MethodCeline George
Odoo provides an option for creating a module by using a single line command. By using this command the user can make a whole structure of a module. It is very easy for a beginner to make a module. There is no need to make each file manually. This slide will show how to create a module using the scaffold method.
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
Executive Directors Chat Leveraging AI for Diversity, Equity, and InclusionTechSoup
Let’s explore the intersection of technology and equity in the final session of our DEI series. Discover how AI tools, like ChatGPT, can be used to support and enhance your nonprofit's DEI initiatives. Participants will gain insights into practical AI applications and get tips for leveraging technology to advance their DEI goals.
2. Deadlocks
• Resource
• Introduction to deadlocks
• The ostrich algorithm
• Deadlock detection and recovery
• Deadlock avoidance
• Deadlock prevention
• Other issues
3. 3
Resources
• Examples of computer resources
– Printers
– tape drives
– Tables (systems internal table)
– Semaphores ( critical section)
• Processes need access to resources in reasonable order
• Suppose a process holds resource A and requests
resource B
– at same time another process holds B and requests A
– both are blocked and remain so……… this situation is called
DEADLOCK
I/O device
( hardware)
4. 4
Resources (1)
• Deadlocks occur when …
– processes are granted exclusive access to devices
– we refer to these devices generally as resources.
Resourses :
A resource Can be hardware device ( eg. Tape drive, printer) ,
a piece of information ( a locked record in a database )
For some resources several identical instances are available ( 3 tape
drive)
• A resource is any thing that must be acquired , used. And
released over the course of time
5. Resources (2)
• Preemptable resources
– can be taken away from a process with no ill
effects
– eg : Memory ( by swapping )
• Nonpreemptable resources
– will cause the process to fail if taken away
– eg: CD ROM ( result garbled CD – Computational failure)
In general deadlock involve with preemptable resourses can
be solved by reallocationg resourses from one process to
another .
Our discussion focus on nonpreemtable resourses
7. 7
Resources (2)
• Sequence of events required to use a
resource
1. request the resource
2. use the resource
3. release the resource
• Must wait if request is denied
– requesting process may be blocked ( eg:semaphore)
– may fail with error code ( error notice)
Request can ne placed by request system call( I/O device, tables ect.)
For some kind of resources ( critical section resources) the user
process can manage using semaphores
8. 8
Introduction to Deadlocks
• Formal definition :
A set of processes is deadlocked if each process in the set is waiting
for an event that only another process in the set can cause
• Usually the event is release of a currently held resource
• None of the processes can …
– run
– release resources
– be awakened
This kind of deadlock is called Resource Deadlock( this is probably
the most common kind )
9. 9
Four Conditions for Resource Deadlock
1. Mutual exclusion condition
• each resource assigned to 1 process or is available
1. Hold and wait condition
• process holding resources can request additional
1. No preemption condition
• previously granted resources cannot forcibly taken away
1. Circular wait condition
• must be a circular chain of 2 or more processes
• each is waiting for resource held by next member of the
chain
10. • The four condition relates to a policy that a
system can have /not have
Can a given resource be assigned to more than one
process at once ?
Can a process hold a resource and ask for another?
Can resource be preemted?
Can circular wait exist?
11. 11
Deadlock Modeling (1)
• Modeled with directed graphs
( 1972 Holt showed how the four condition can be modeled)
– resource R assigned to process A
– process B is requesting/waiting for resource S
– process C and D are in deadlock over resources T and U
12. 12
Deadlock Modeling (2)
Resource allocation graphs
• Resource allocation
modeled by directed
graphs
• Example 1:
– Resource R assigned to
process A
• Example 2:
– Process B is requesting /
waiting for resource S
• Example 3:
– Process C holds T, waiting for
U
– Process D holds U, waiting
for T
R
A
S
B
U
T
DC
15. Four Strategies dealing with dead lock
1. Just ignore the problem . May be if you ignore it, it will
ignore you
2.Detection & recovery. Let deadlock happen, detect them
and take action
3.Dynamic avoidance by careful resource allocation
4.Prevention, by structurally negating one of the four
condition.
16. 16
The Ostrich Algorithm
• Pretend there is no problem
“Hide your head in the sand and pretend there is no problem at all “
• Reasonable if
– deadlocks occur very rarely
– cost of prevention is high
• It is a trade off between
– convenience
– correctness
17. 2.Detection & recovery
• The system does not prevent deadlock from
occurring .Instead …………….
-it lets them occur
-tries to detect when this happens
-and take some action to recover after that.
18. 18
Detecting deadlocks using graphs
An example : Detection with One Resource of Each Type
•Process holdings and requests in the table and in the graph
(they’re equivalent)
•Graph contains a cycle => deadlock!
– Easy to pick out by looking at it (in this case)
– Need to mechanically detect deadlock
•Not all processes are deadlocked (A, C, F not in deadlock)
R A
S
F
W
C
Process Holds Wants
A R S
B T
C S
D U S,T
E T V
F W S
G V U
ED
G
B
T
VU
19. 19
Deadlock detection algorithm
• General idea: try to find
cycles in the resource
allocation graph
• Algorithm: depth-first
search at each node
– Mark arcs as they’re
traversed
– Build list of visited nodes
– If node to be added is
already on the list, a cycle
exists!
• Cycle == deadlock
For each node N in the graph {
Set L = empty list
unmark all arcs
Traverse (N,L)
}
If no deadlock reported by now, there isn’t any
define Traverse (C,L) {
If C in L, report deadlock!
Add C to L
For each unmarked arc from C {
Mark the arc
Set A = arc destination
/* NOTE: L is a
local variable */
Traverse (A,L)
}
}
20. 20
Resources with multiple instances
• Previous algorithm only works if there’s one
instance of each resource
• If there are multiple instances of each
resource, we need a different method
– Track current usage and requests for each process
– To detect deadlock, try to find a scenario where
all processes can finish
– If no such scenario exists, we have deadlock
21. Example
•E=(4, 2, 3, 1 ) A=(2, 1, 0, 0)
( Resource in existence) ( Resource Available)
•3 processes
0 0 1 0 2 0 0 1
c= 2 0 0 1 R= 1 0 1 0
0 1 2 0 2 1 0 0
current allocation matrix Request matrix
-p3 can run and return all its resources giving A=(2 , 2, 2 ,0 )
- At this point p2 can run A( 4 2 2 1)
-Now P1 can run no dead lock in the system
Tape , plotters, scanner, Cd rom Tape , plotters, scanner, Cd rom
22. Chapter 3 22
Deadlock detection algorithm
A B C D
Avail 2 3 0 1
Process A B C D
1 0 3 0 0
2 1 0 1 1
3 0 2 1 0
4 2 2 3 0
Process A B C D
1 3 2 1 0
2 2 2 0 0
3 3 5 3 1
4 0 4 1 1
HoldWant
current=avail;
for (j = 0; j < N; j++) {
for (k=0; k<N; k++) {
if (finished[k])
continue;
if (want[k] < current) {
finished[k] = 1;
current += hold[k];
break;
}
if (k==N) {
printf “Deadlock!n”;
// finished[k]==0 means process is in
// the deadlock
break;
}
}
Note: want[j],hold[j],current,avail are arrays!
23. 23
Recovery from Deadlock (1)
• Recovery through preemption
– take a resource from some other process
– depends on nature of the resource
• Recovery through rollback
– checkpoint a process periodically
– use this saved state
– restart the process if it is found deadlocked
24. 24
Recovery from Deadlock (2)
• Recovery through killing processes
– crudest but simplest way to break a deadlock
– kill one of the processes in the deadlock cycle
– the other processes get its resources
– choose process that can be rerun from the
beginning
25. Dead Lock Avoidance
• Question
Is there an algorithm that can avoid deadlock
by making the right choice at right time????
Ans: Yes – we can avoid dead lock , but only if
certain information is available in advance
The main Algorithm for avoiding algorithm is
based on safe state
27. Safe & Unsafe Stataes
• At any Instant of time we have E, A , C, A
• A state is said to be safe if there is some scheduling order in
which every process can run to completion even if all of them
suddenly request there maximum number of resources
immediate
Example: Three processes A, B, C , & one resource type ( 10
Instances ( copies))
28. Safe and unsafe states
Has Max
A 3 9
B 2 4
C 2 7
Free: 3
Has Max
A 3 9
B 4 4
C 2 7
Free: 1
Has Max
A 3 9
B 0 -
C 2 7
Free: 5
Has Max
A 3 9
B 0 -
C 7 7
Free: 0
Has Max
A 3 9
B 0 -
C 0 -
Free: 7
Demonstration that the first state is safe
Has Max
A 3 9
B 2 4
C 2 7
Free: 3
Has Max
A 4 9
B 2 4
C 2 7
Free: 2
Has Max
A 4 9
B 4 4
C 2 7
Free: 0
Has Max
A 4 9
B 0 -
C 2 7
Free: 4
Demonstration that the second state is unsafe
29. Banker's Algorithm for a single resource
( Dijkstra
• It is an extension of deadlock detection algorithm ( One
resource of each type)
• It is modeled one the way a small time banker who is dealing
with customer to whom he has to granted credits
• Example : Four customers . To whom hes has granted a
certain number of credits ( Iunit- 1K$)
(in our case customers are process , cdret – resources ( say tape
driver) and the banker is the OS
30. Banker's Algorithm for a single resource ( Dijkstra)
Has Max
A 0 6
B 0 5
C 0 4
D 0 7
Free: 10
Has Max
A 1 6
B 1 5
C 2 4
D 4 7
Free: 2
Has Max
A 1 6
B 2 5
C 2 4
D 4 7
Free: 1
• Bankers’ algorithm: before granting a request, ensure that a sequence exists
that will allow all processes to complete
– Use previous methods to find such a sequence
– If a sequence exists, allow the requests
– If there’s no such sequence, deny the request
• Can be slow: must be done on each request!
Any sequence finishes C,B,A,D finishes Deadlock (unsafe state)
31. Process D can finish , then A or E followed by rge rest
Example of banker's algorithm with multiple resources
Banker's Algorithm for multiple
resources
C
R
32. Chapter 3 32CS 1550, cs.pitt.edu (originaly
modified by Ethan L. Miller and
Preventing deadlock
• Deadlock can be completely prevented!
• Ensure that at least one of the conditions for
deadlock never occurs
– Mutual exclusion
– Circular wait
– Hold & wait
– No preemption
• Not always possible…
33. Chapter 3 33
Eliminating mutual exclusion
• Some devices (such as printer) can be spooled
– Only the printer daemon uses printer resource
– This eliminates deadlock for printer
• Not all devices can be spooled
• Principle:
– Avoid assigning resource when not absolutely
necessary
– As few processes as possible actually claim the
resource
34. 34
Attacking “hold and wait”
• Require processes to request resources before starting
– A process never has to wait for what it needs
• This can present problems
– A process may not know required resources at start of run
– This also ties up resources other processes could be using
• Processes will tend to be conservative and request resources
they might need
• Variation: a process must give up all resources before making a new
request
– Process is then granted all prior resources as well as the new ones
– Problem: what if someone grabs the resources in the meantime—
how can the process save its state?
35. Chapter 3 35CS 1550, cs.pitt.edu (originaly
modified by Ethan L. Miller and
Attacking “no preemption”
• This is not usually a viable option
• Consider a process given the printer
– Halfway through its job, take away the printer
– Confusion ensues!
• May work for some resources
– Forcibly take away memory pages, suspending the process
– Process may be able to resume with no ill effects
36. Chapter 3 36CS 1550, cs.pitt.edu (originaly
modified by Ethan L. Miller and
Attacking “circular wait”
• Assign an order to
resources
• Always acquire
resources in numerical
order
– Need not acquire them
all at once!
• Circular wait is
prevented
– A process holding
resource n can’t wait for
resource m
if m < n
A
1
B
C
D
23
37. 37
Deadlock prevention: summary
• Mutual exclusion
– Spool everything
• Hold and wait
– Request all resources initially
• No preemption
– Take resources away
• Circular wait
– Order resources numerically