Video Capítulo 8: Impasses. Silberschatz, Galvin and Gagne  2002 3.2 Video Operating System Concepts Assuntos n Modelo de Sistemas n Carcterização de.

Slides:



Advertisements
Apresentações semelhantes
Presenter’s Notes Some Background on the Barber Paradox
Advertisements

Deadlocks Professora: Lúcia Drummond. Deadlocks Recursos: hardware ou informação Preemptivo Não preemptivo Uso do Recurso: 1. Pedido (Request ou Open)
Sistemas Operativos Paulo Marques Departamento de Eng. Informática Universidade de Coimbra 2006/2007 Apresentação.
Deadlocks - Impasses 3.1. Recurso 3.2. Introdução aos deadlocks
Chapter 4: Threads.
Capítulo 7: Deadlocks.
DIRETORIA ACADÊMICA NÚCLEO DE CIÊNCIAS HUMANAS E ENGENHARIAS DISCIPLINA: INGLÊS FUNDAMENTAL - NOITE PROFESSOR: JOSÉ GERMANO DOS SANTOS PERÍODO LETIVO
Recursos Recurso: objeto físico ou abstrato necessário para que uma tarefa seja executada exemplos: tempo de CPU, memória principal, dispositivos de E/S,
Deadlock Marcos José Santana Regina Helena Carlucci Santana
Deadlock SISTEMAS OPERACIONAIS
Operating System Concepts
Silberschatz and Galvin Operating System Concepts Unidade 1: Introdução O que é um sistema operacional? Systemas simples em lote (batch) Sistemas.
Capítulo 3 Deadlocks - Impasses 3.1. Recurso
DeadLock Sistemas Operacionais I
Filosofia da mente, psicologia cognitiva
COM SOM Barbra Streisand Melhor visualização no Power Point 2000.
Sistemas Operacionais
METODOLOGIA PARA DESENVOLVIMENTO DE SISTEMAS Prof. Dr. rer. nat. Daniel D. Abdala 1.
Avaliação Constituição dos grupos de trabalho:
Capítulo 7: Deadlocks.
Concorrência STRD.
Uma Abordagem Baseada em Modelos para Detecção de Situações em Sistemas Sensíveis ao Contexto Izon Thomaz Mielke Orientadora: Patrícia Dockhorn Costa.
Prof. Alexandre Monteiro Recife
Capítulo 7: Deadlocks.
V IDA F ELIZ Happy Life Joanna de Ângelis. Se a tua palavra não tiver o objetivo de auxiliar, não a apresentes para criticar. If your word does not have.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Capítulo 11: Implementação de Sistemas de Arquivos.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Capítulo 13: Sistemas de E/S.
Fundamentos da teoria dos semicondutores
INFORMATION SECURITY IN ORGANIZATIONS Ana Helena da Silva, MCI12017 Cristiana Coelho, MCI12013.
Chapter 1 - The Foundations for a New Kind of Science Wolfram, Stephen. A New Kind of Science. Wolfram Media, Inc
© 2012 Autodesk Autodesk Revit para projetos executivos de arquitetura Módulo 3: Utilizando Legends Tiago Marçal Ricotta Gerente de Projetos – Brasoftware.
Biologia Molecular e Celular de Nematóides BMP fone: segundas e sextas – 9:00hs
Desenvolvimento Empresarial Aula 6 – Business Process Modeling Notation – Parte 3 Prof.: Guilherme Amorim Data: 28/03/2014.
Imagine there’s no heaven Imagine que não existe o paraiso It’s easy if you try É fácil se você tentar.
© 2012 Autodesk Autodesk Revit para projetos executivos de arquitetura Módulo 6: Quantitativos de áreas precisos Tiago Marçal Ricotta Gerente de Projetos.
© 2012 Autodesk Autodesk Revit para projetos executivos de arquitetura Módulo 5: Trabalhando em colaboração Tiago Marçal Ricotta Gerente de Projetos –
Autodesk Revit para projetos executivos de arquitetura Módulo 4: Representação gráfica de diversas fases Tiago Marçal Ricotta Gerente de Projetos – Brasoftware.
Imagine there's no heaven it's easy if you try no hell below us above us only sky Imagine all the people living for today... Imagine there's no countries.
Cigré/Brasil CE B5 – Proteção e Automação Seminário Interno de Preparação para o Colóquio de Madri 2007 Rio de Janeiro, outubro/07.
IEEE PES General Meeting, Tampa FL June 24-28, 2007 Conferência Brasileira de Qualidade de Energia Santos, São Paulo, Agosto 5-8, Chapter 1: An.
Imagine John Lennon.
Gotas de Crystal Remember Lembre-se I will still be here Eu estarei aqui As long as you hold me Enquanto você me guardar In your memory Em sua lembrança.
Video Capítulo 7: Sincronização de Processos. Silberschatz, Galvin and Gagne  Video Operating System Concepts Assuntos n Cenário n O problema.
Sistemas Operacionais
XML Namespaces XML Namespaces provê um método para evitar conflito de nomes de elementos.
Database System Concepts ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 16 : Concurrency Control.
MAC Engenharia de Software Marco A. GerosaIME / USP Mais sobre análise e Outros Diagramas UML MAC0332 Engenharia de Software Marco Aurélio Gerosa.
Gerenciamento de Processos
O que são os alertas do Google?
Broadcasting in Brazil Octavio Penna Pieranti Director/Secretariat of Electronic Communications Ministry of Communications WIPO Meeting on South-South.
Deadlocks Impasses Vinícius Pádua.
Remember Lembre se Remember Lembre se I will still be here Eu estarei aqui I will still be here Eu estarei aqui As long as you hold me Enquanto você.
Deadlocks.
Limit Equlibrium Method. Limit Equilibrium Method Failure mechanisms are often complex and cannot be modelled by single wedges with plane surfaces. Analysis.
Aula Prática 5. Fluxes (Problem 1.07) Consider the flow in a rectangular duct, formed by two paralell plates (width b=1m and height 2h= 30cm) where air.
© 2007 IBM Corporation Academic Initiative 07/05/07 Aula 2 – Parte 1: Java Basics Autores: Argemiro José de Juliano Marcos
Another day has gone Mais um dia se passou I'm still all alone E eu continuo muito só How could this be? Como pode ser? You're not here with me Você.
Pearson Education Sistemas Operacionais Modernos – 2ª Edição 1 Sistemas Operacionais IESP - FATEC-PB Professor: Gustavo Wagner
APPLICATIONS OF DIFFERENTIAL EQUATIONS - ANIL. S. NAYAK.
Knetworks CEGER – Centro de Gestão da Rede Informática do Governo - Rua Almeida Brandão, LISBOA PORTUGAL -
Abril 2016 Gabriel Mormilho Faculdade de Economia, Administração e Contabilidade da Universidade de São Paulo Departamento de Administração EAD5853 Análise.
Pesquisa Operacional aplicada à Gestão de Produção e Logística Prof. Eng. Junior Buzatto Case 4.
Pesquisa Operacional aplicada à Gestão de Produção e Logística Prof. Eng. Junior Buzatto Case 3.
Phases of Hackers. Module 1: Today’s Threat Landscape Module 2: Key Principles of Security Module 3: Understanding your enemy! Module 4: Phases of Hackers.
UNIVERSIDADE FEDERAL DE GOIÁS INSTITUTO DE INFORMÁTICA
Visão geral do Aprendizado de máquina
Split clique graph complexity
Wondershare software On the [View] menu, point to [Master], and then click [Slide Master] or [Notes Master].
Top-Down Parsing Teoría de Autómatas y Lenguajes Formales
Pesquisadores envolvidos Recomenda-se Arial 20 ou Times New Roman 21.
Transcrição da apresentação:

Video Capítulo 8: Impasses

Silberschatz, Galvin and Gagne  Video Operating System Concepts Assuntos n Modelo de Sistemas n Carcterização de impasses n Métodos para Evitar impasses n Prevenção de impasses n Detecção de impasses n Recuperação de impasse n Combinando Abordagens

Silberschatz, Galvin and Gagne  Video Operating System Concepts Impasse n Conjunto de processos bloqueados n Cada processo necessita de um recurso utilizado por outro processo do conjunto

Silberschatz, Galvin and Gagne  Video Operating System Concepts Exemplo de Impasse n Sistema com duas unidades de fita F Processos P 1 e P 2 4 cada um como uma unidade e precisando da outra. F P0 P1 F Espera(A); Espera(B) F Espera(B); Espera(A)

Silberschatz, Galvin and Gagne  Video Operating System Concepts Exemplo da Ponte n Tráfego em uma direção n Cada parte da ponte F um recurso. n Se um impasse ocorre F pode ser resolvido se um carro voltar n Muitos carros podem ter que voltar F se ocorrer um impasse

Silberschatz, Galvin and Gagne  Video Operating System Concepts Modelo n Classes de recursos R 1, R 2,..., R m F Ciclos de CPU, Espaço de Memória,Dispositivos de E/S) n Cada recurso R i tem W i instâncias. n Cada processo segue a seguinte sequência para utilizar um recurso F requisição F uso F liberação

Silberschatz, Galvin and Gagne  Video Operating System Concepts Caracterização Para ocorrer um impasse quatro condições devem ser satisfeitas: F Exclusão Mútua F “Pega e espera” F Inexistência de Preempção F Espera Circular

Silberschatz, Galvin and Gagne  Video Operating System Concepts Exclusão Mútua n Apenas um processo pode usar o recurso a cada instante n Ex: impressora F Se dois processos imprimem simultaneamente, o saída é embaralhada

Silberschatz, Galvin and Gagne  Video Operating System Concepts “Pega e Espera” n Hold and Wait n Um processo que já “pegou” pelo menos um recurso espera por outro recurso que está alocado para outro processo

Silberschatz, Galvin and Gagne  Video Operating System Concepts Inexistência de Preempção n Um recurso só poder ser liberado voluntáriamente pelo processo que o possui, depois de ter completado sua tarefa

Silberschatz, Galvin and Gagne  Video Operating System Concepts Espera Circular n Existe um conjunto {P0, P1,..., Pn} de processos tais que P0 está esperando por um recurso que está alocado para P1, P(x-1) está esperando por um recurso alocado para P(x), e Pn espera por um recurso alocado para P0

Silberschatz, Galvin and Gagne  Video Operating System Concepts Grafo de Alocação de Recursos n Um conjunto de vértices V e arestas A n V é particionado em dois tipos: F P = {P1, P2,..., Pn}, o conjuto de todos os processos no sistema F R={R1, R2,..., Rn} o conjunto de todos os tipos de recursos no sistema n Aresta de pedido F Aresta direcionada Pi -> Ri n Aresta de alocação F Aresta direcionada Ri -> Pi

Silberschatz, Galvin and Gagne  Video Operating System Concepts Grafo de Alocação de Recursos (cont) n Processo n Recurso com 4 instâncias n Pi requisita instância de Rj n Pi “pegou” uma instância de Rj PiPi PiPi RjRj RjRj

Silberschatz, Galvin and Gagne  Video Operating System Concepts Example of a Resource Allocation Graph

Silberschatz, Galvin and Gagne  Video Operating System Concepts Resource Allocation Graph With A Deadlock

Silberschatz, Galvin and Gagne  Video Operating System Concepts Resource Allocation Graph With A Cycle But No Deadlock

Silberschatz, Galvin and Gagne  Video Operating System Concepts Basic Facts n If graph contains no cycles  no deadlock. n If graph contains a cycle  F if only one instance per resource type, then deadlock. F if several instances per resource type, possibility of deadlock.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Methods for Handling Deadlocks n Ensure that the system will never enter a deadlock state. n Allow the system to enter a deadlock state and then recover. n Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems, including UNIX.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Deadlock Prevention n Mutual Exclusion – not required for sharable resources; must hold for nonsharable resources. Restrain the ways request can be made.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Deadlock Prevention (Cont.) n Hold and Wait – must guarantee that whenever a process requests a resource, it does not hold any other resources. F Require process to request and be allocated all its resources before it begins execution, or allow process to request resources only when the process has none. F Low resource utilization; starvation possible.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Deadlock Prevention (Cont.) n No Preemption – F 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. F Preempted resources are added to the list of resources for which the process is waiting. F Process will be restarted only when it can regain its old resources, as well as the new ones that it is requesting.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Deadlock Prevention (Cont.) n Circular Wait – F impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Deadlock Avoidance n Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need. n The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition. n Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes. Requires that the system has some additional a priori information available.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Safe State n When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state. n System is in safe state if there exists a safe sequence of all processes.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Safe State n Sequence is safe if for each P i, the resources that Pi can still request can be satisfied by currently available resources + resources held by all the P j, with j<I.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Safe State F If P i resource needs are not immediately available, then P i can wait until all P j have finished. F When P j is finished, P i can obtain needed resources, execute, return allocated resources, and terminate. F When P i terminates, P i+1 can obtain its needed resources, and so on.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Basic Facts n If a system is in safe state  no deadlocks. n If a system is in unsafe state  possibility of deadlock. n Avoidance  ensure that a system will never enter an unsafe state.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Safe, Unsafe, Deadlock State

Silberschatz, Galvin and Gagne  Video Operating System Concepts Resource-Allocation Graph Algorithm n Claim edge P i  R j indicated that process P j may request resource R j ; represented by a dashed line. n Claim edge converts to request edge when a process requests a resource. n When a resource is released by a process, assignment edge reconverts to a claim edge. n Resources must be claimed a priori in the system.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Resource-Allocation Graph For Deadlock Avoidance

Silberschatz, Galvin and Gagne  Video Operating System Concepts Unsafe State In Resource-Allocation Graph

Silberschatz, Galvin and Gagne  Video Operating System Concepts Banker’s Algorithm n Multiple instances. n Each process must a priori claim maximum use. n When a process requests a resource it may have to wait. n When a process gets all its resources it must return them in a finite amount of time.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Data Structures for the Banker’s Algorithm n Available n Max n Allocation: n Need: Let n = number of processes, and m = number of resources types.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Available n Available: Vector of length m. If available [j] = k, there are k instances of resource type R j available.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Max n Max: n x m matrix. If Max [i,j] = k, then process P i may request at most k instances of resource type R j.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Allocation n Allocation: n x m matrix. If Allocation[i,j] = k then P i is currently allocated k instances of R j.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Need n Need: n x m matrix. If Need[i,j] = k, then P i may need k more instances of R j to complete its task. Need [i,j] = Max[i,j] – Allocation [i,j].

Silberschatz, Galvin and Gagne  Video Operating System Concepts Safety Algorithm 1.Let Work and Finish be vectors of length m and n, respectively. Initialize: Work = Available Finish [i] = false for i - 1,3, …, n. 2.Find and i such that both: (a) Finish [i] = false (b) Need i  Work If no such i exists, go to step 4. 3.Work = Work + Allocation i Finish[i] = true go to step 2. 4.If Finish [i] == true for all i, then the system is in a safe state.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Resource-Request Algorithm for Process P i Request = request vector for process P i. If Request i [j] = k then process P i wants k instances of resource type R j. 1.If Request i  Need i go to step 2. Otherwise, raise error condition, since process has exceeded its maximum claim. 2.If Request i  Available, go to step 3. Otherwise P i must wait, since resources are not available. 3.Pretend to allocate requested resources to P i by modifying the state as follows: Available = Available = Request i ; Allocation i = Allocation i + Request i ; Need i = Need i – Request i;; If safe  the resources are allocated to P i. If unsafe  P i must wait, and the old resource-allocation state is restored

Silberschatz, Galvin and Gagne  Video Operating System Concepts Example of Banker’s Algorithm n 5 processes P 0 through P 4 ; 3 resource types A (10 instances), B (5instances, and C (7 instances). n Snapshot at time T 0 : AllocationMaxAvailable A B CA B C A B C P P P P P

Silberschatz, Galvin and Gagne  Video Operating System Concepts Example (Cont.) n The content of the matrix. Need is defined to be Max – Allocation. Need A B C P P P P P n The system is in a safe state since the sequence satisfies safety criteria.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Example P 1 Request (1,0,2) (Cont.) n Check that Request  Available (that is, (1,0,2)  (3,3,2)  true. AllocationNeedAvailable A B CA B CA B C P P P P P n Executing safety algorithm shows that sequence satisfies safety requirement. n Can request for (3,3,0) by P 4 be granted? n Can request for (0,2,0) by P 0 be granted?

Silberschatz, Galvin and Gagne  Video Operating System Concepts Deadlock Detection n Allow system to enter deadlock state n Detection algorithm n Recovery scheme

Silberschatz, Galvin and Gagne  Video Operating System Concepts Single Instance of Each Resource Type n Maintain wait-for graph F Nodes are processes. F P i  P j if P i is waiting for P j. n Periodically invoke an algorithm that searches for a cycle in the graph. n An algorithm to detect a cycle in a graph requires an order of n 2 operations, where n is the number of vertices in the graph.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Resource-Allocation Graph and Wait- for Graph Resource-Allocation GraphCorresponding wait-for graph

Silberschatz, Galvin and Gagne  Video Operating System Concepts Several Instances of a Resource Type n Available: A vector of length m indicates the number of available resources of each type. n Allocation: An n x m matrix defines the number of resources of each type currently allocated to each process. n Request: An n x m matrix indicates the current request of each process. If Request [i j ] = k, then process P i is requesting k more instances of resource type. R j.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Detection Algorithm 1.Let Work and Finish be vectors of length m and n, respectively Initialize: (a) Work = Available (b)For i = 1,2, …, n, if Allocation i  0, then Finish[i] = false;otherwise, Finish[i] = true. 2.Find an index i such that both: (a)Finish[i] == false (b)Request i  Work If no such i exists, go to step 4.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Detection Algorithm (Cont.) 3.Work = Work + Allocation i Finish[i] = true go to step 2. 4.If Finish[i] == false, for some i, 1  i  n, then the system is in deadlock state. Moreover, if Finish[i] == false, then P i is deadlocked. Algorithm requires an order of O(m x n 2) operations to detect whether the system is in deadlocked state.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Example of Detection Algorithm n Five processes P 0 through P 4 ; three resource types A (7 instances), B (2 instances), and C (6 instances). n Snapshot at time T 0 : AllocationRequestAvailable A B C A B C A B C P P P P P n Sequence will result in Finish[i] = true for all i.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Example (Cont.) n P 2 requests an additional instance of type C. Request A B C P P P P P n State of system? F Can reclaim resources held by process P 0, but insufficient resources to fulfill other processes; requests. F Deadlock exists, consisting of processes P 1, P 2, P 3, and P 4.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Detection-Algorithm Usage n When, and how often, to invoke depends on: F How often a deadlock is likely to occur? F How many processes will need to be rolled back? 4 one for each disjoint cycle n If detection algorithm is invoked arbitrarily, there may be many cycles in the resource graph and so we would not be able to tell which of the many deadlocked processes “caused” the deadlock.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Recovery from Deadlock: Process Termination n Abort all deadlocked processes. n Abort one process at a time until the deadlock cycle is eliminated. n In which order should we choose to abort? F Priority of the process. F How long process has computed, and how much longer to completion. F Resources the process has used. F Resources process needs to complete. F How many processes will need to be terminated. F Is process interactive or batch?

Silberschatz, Galvin and Gagne  Video Operating System Concepts Recovery from Deadlock: Resource Preemption n Selecting a victim – minimize cost. n Rollback – return to some safe state, restart process for that state. n Starvation – same process may always be picked as victim, include number of rollback in cost factor.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Combined Approach to Deadlock Handling n Combine the three basic approaches F prevention F avoidance F detection allowing the use of the optimal approach for each of resources in the system. n Partition resources into hierarchically ordered classes. n Use most appropriate technique for handling deadlocks within each class.

Silberschatz, Galvin and Gagne  Video Operating System Concepts Traffic Deadlock for Exercise 8.4