SlideShare une entreprise Scribd logo
1  sur  72
Deadlock Handling
Objectives
 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
   Defined as the permanent blocking of a
    set of processes that compete for a
    system resource, including database
    records and communication lines

   A situation wherein each of a collection of
    processes is waiting for something from
    other processes in the collection. Since all
    are waiting, none can provide any of the
    things being waited for.
Deadlock
   A situation wherein a process is
    requesting a resource which is withheld
    by another process and never get hold
    of the resource.
Example
   System has 2 tape drives
     P1 and P2 each hold one tape drive and
     each needs another one.


   Semaphores A and B initialized to 1
     P0                P1
     Wait(A);          Wait(B);
     Wait(B);          Wait(A);
Deadlock
   Deadlock occurs when a set of
    processes are in a wait state, because
    each process is waiting for a resource
    that is held by some other waiting
    process. Therefore, all deadlocks
    involve conflicting resource that are
    needed by two or more processes.
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).
    Several cars may have to be backed up if a deadlock occurs.
    Starvation is possible.
Deadlock
   Unlike some other problems in
    multiprogramming systems, there is no
    efficient solution to the deadlock
    problem in the general case. It is one
    area where there is a strong theory but it
    is completely ignored in practice
    because solutions to deadlock are
    expensive.
Resource
   A hardware device (e.g. tape drive,
    memory)

   A piece of information (e.g. a locked
    record in a database)
General Categories of Resources
   Reusable – something that can be
    safely used by one process at a time
    and is not depleted by that use.
    Processes obtain resources that they
    later release for reuse by others.
     Example:
     CPU, Memory, specific I/O devices or files.
General Categories of Resources
   Consumable – these can be created and
    destroyed. When a resource is acquired
    by a process, the resource ceases to
    exist.
     Examples:
     Interrupts, signals, messages.
Types of Resources
   Preemptable resource – a resource that
    can be taken away from the process
    owning it with no ill effect (needs
    save/restore)

   Example: Memory or CPU
Types of Resources
   Non-preemptable – a resource that
    cannot be taken away from its current
    owner without causing the computation
    to fail.

   Example: Printer or floppy disk.
Note
   Deadlocks occur when sharing reusable
    and non-preemptable resources
Pop Exercise

   Classify the following as either sharable
    or non-sharable
     A. Hard disk
     B. file
     C. keyboard
System Model
 System consists of a finite number of
  resources and a finite number of
  processes competing for resources.
 Resources are partitioned into several
  types, each of which consists of some
  number of identical instances
System Model
   When a process requests an instance of
    a resource type, the allocation of any
    instance of the type will satisfy the
    request (otherwise, resource types have
    not been defined properly).
Protocol for resource utilization
 Request – the process will request for a
  certain resource. If the request cannot
  be granted immediately, then the
  requesting process must wait until it can
  acquire the resource.
 Use – the process can operate the
  resource
 Release – the process relinquishes the
  resources.
Note
   A set of processes is deadlocked when
    every process in the set is waiting for an
    event that can be caused only by
    another process in the set.
Deadlock Characterization
Deadlock can arise if four conditions hold simultaneously:
 Mutual exclusion: only one process at a time can use a
  resource.
 Hold and wait: a process holding at least one resource is
  waiting to acquire additional resources held by other processes.
 No preemption: a resource can be released only voluntarily by
  the process holding it, after that process has completed its task.
 Circular wait: there exists a set {P0, P1, …, P0} 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 P0 is waiting for a resource that is held by P0.
Additional characteristic
   PROCESS IRREVERSIBLE – Unable to
    reset to an earlier state where resources
    are not held.
Systems avoiding deadlocks
 Systems involving only shared
  resources cannot deadlock. – negates
  mutual exclusion
 System that aborts processes which is
  requesting a resource but currently
  being used. – negates hold and wait
 Preemption may be possible if a process
  does not use its resources until it has
  acquired all it needs – negates no
  preemption
Systems…
 Transaction processing systems provide
  checkpoints so that processes may back
  out of a transaction. – negates
  irreversible process
 System that detects or avoids deadlocks
  – prevents cycle.
Resource-Allocation Graph (RAG)
   Consists of a set of vertices V and a set of edges
    E. Devised by Holt in 1972.

   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 P1 → Rj
   assignment edge – directed edge Rj → Pi
Resource-Allocation Graph (RAG)


    Process

    Resource Type with 4 instances

    Pi requests instance of Rj        Pi
                                                 Rj



    Pi is holding an instance of Rj        Pi
                                                      Rj
Example
 P = P1, P2, P3
 R = R1, R2, R3, R4
 Instances: R1=1, R2=2, R3=1, R4=3


   E={ P1 -> R1, P2 -> R3, R1 -> P2, R2 ->
    P1, R2 -> P2, R3 -> P3,

   Question: is there a deadlock?
Example
Resource Allocation Graph With A
Deadlock
Graph With A Cycle But No Deadlock
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.
Methods for handling deadlocks
   3 strategies:

1. Ostrich Solution: Ignore the problem
   and pretend deadlocks never occur in
   the system. Used by most OS, including
   Unix
Methods for handling deadlocks
2. Ensure that the system will never enter a
   deadlock state.

 Deadlock prevention – Design a system
  in such a way that the 4 conditions
  leading to deadlock will never occur.
 Deadlock avoidance – make a decision
  dynamically checking whether the request
  will, if granted, potentially lead to a
  deadlock or not.
Methods for handling deadlocks
3. Allow the system to enter a deadlock
   state and recover

   Deadlock detection and recovery
Deadlock Prevention
   Preventing the occurrence of one of the
    necessary conditions leading to
    deadlock. Deadlock prevention strategy
    is very conservative. It solves the
    problem of deadlock by limiting access
    to resources and by imposing
    restrictions on processes.
Mutual Exclusion
   In general, this condition cannot be
    required for non-sharable resources but
    is a must for sharable resources.
Hold and Wait
   Must guarantee that whenever a process requests a
    resource, it does not hold any other resources. A
    process is blocked until all requests can be granted
    simultaneously.

   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.

   Low resource utilization; starvation possible
No preemption
 If a process that is holding some
  resource 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
  new ones that it is requesting.
Circular Wait
   Impose a total ordering of all resource
    types, and require that each process
    requests resources in an increasing
    order of enumeration.
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.
Ways to avoid deadlock by careful
resource allocation
1. Resource trajectories
2. Safe/Unsafe states
3. Dijkstra’s Banker’s Algorithm
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.
Safe, Unsafe , Deadlock State
Avoidance algorithms
   Single instance of a resource type. Use
    a resource-allocation graph

   Multiple instances of a resource type.
    Use the banker’s algorithm
Resource-Allocation Graph Scheme
   Claim edge Pi → Rj indicated that process Pj may request
    resource Rj; represented by a dashed line.

   Claim edge converts to request edge when a process
    requests a resource.

   Request edge converted to an assignment edge when the
    resource is allocated to the process.

   When a resource is released by a process, assignment edge
    reconverts to a claim edge.

   Resources must be claimed a priori in the system.
Resource-Allocation Graph
Unsafe State In Resource-Allocation Graph
Sample Algorithm
   Given the RAG of the system (Initially on
    a safe state, grant a resource allocation
    request if and only if doing so will not
    introduce a cycle in the graph. (taking
    into consideration all assignment,
    request and claim edges). Otherwise,
    the requesting process has to wait.
Sample Algorithm
1. Operation: P2 requests R3
   Action: Request granted
   System State: SAFE

2. Operation: P3 requests R2
   Action: REQUEST DENIED!!!
   System State: Leads to deadlock
Sample 2
   Consider a system with 15 identical instances of a resource

    Process        Max Need          Curr Allo      Remaining
      P0              14                5
      P1              10                5
      P2               3                2
 Currently available resource: 15 – (5+5+2) = 3
 Is it safe?
     Yes with a safe sequence of <P2, P1, P0>
   What if P0 requests two more resources, will it be granted?
     No, OS cannot satisfy remaining needs of all processes. Unsafe.
Sample 3
   Total instances: 8

    Process       Max Need      Curr Allo     Remaining
      P0             5             3
      P1             8             1
      P2             7             2


   Is it safe or unsafe? What is the safe sequence?
Sample 4
   Total instances: 8

    Process     Max Need       Curr Allo    Remaining
      P0           5              3
      P1           8              1
      P2           7              2


   Is it safe or unsafe? What is the safe sequence?
Banker’s Algorithm
   Multiple instances.

   Each process must a priori claim maximum use.

   When a process requests a resource it may have
    to wait.

   When a process gets all its 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.

    Available: Vector of length m. If available [j] = k, there are k
     instances of resource type Rj available.

    Max: n x m matrix. If Max [i,j] = k, then process Pi may request
     at most k instances of resource type Rj.

    Allocation: n x m matrix. If Allocation[i,j] = k then Pi is
     currently allocated k instances of Rj
    .
    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].
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 and 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.
Example of Banker’s Algorithm
 5 processes P0 through P4;
  3 resource types:
       A (10 instances), B (5instances), and C (7 instances).
 Snapshot at time T0:
               Allocation     Max                   Available
               ABC            ABC                   ABC
      P0       010            753                   332
       P1      200            322
       P2      302            902
       P3      211            222
       P4      002            433
Example (Cont.)
   The content of the matrix Need is defined to be Max – Allocation.
                Need
                ABC
        P0      743
        P1      122
        P2      600
        P3      011
        P4      431


   The system is in a safe state since the sequence < P1, P3, P4, P2,
    P0> satisfies safety criteria.
Example: P1 Request (1,0,2)
 Check that Request ≤ Available (that is, (1,0,2) ≤ (3,3,2) ⇒
  true.
               Allocation        Need           Available
               ABC               ABC            ABC
       P0      010               743            230
       P1      302               020
       P2      302               600
       P3      211               011
       P4      002               431
 Executing safety algorithm shows that sequence < P1, P3, P4,
  P0, P2> satisfies safety requirement.
 Can request for (3,3,0) by P4 be granted?
 Can request for (0,2,0) by P0 be granted?
Deadlock detection and recovery
 Implies no conscious effort to
  prevent/avoid deadlocks
 At certain times during processing, the
  system executes an algorithm to
  determine whether or not a deadlock
  has occurred.
 If so, an attempt to recover from the
  deadlock is made.
Detection Algorithm
Single Instance of Each Resource Type

   Maintain wait-for graph
     Nodes are processes.
     Pi → Pj if Pi is waiting for Pj.

   Periodically invoke an algorithm that searches for a cycle in
    the graph. If there is a cycle, there exists a deadlock.

   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.
Resource-Allocation Graph and Wait-for
Graph




      Resource-Allocation Graph   Corresponding wait-for graph
Several Instances of a Resource Type

   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 [ij] = k, then
    process Pi is requesting k more instances of
    resource type. Rj.
Detection Algorithm
1. Let Work and Finish be vectors of length m and n, respectively
   Initialize:
    (a) Work = Available
    n For i = 1,2, …, n, if Allocationi ≠ 0, then
        Finish[i] = false;otherwise, Finish[i] = true.

2. Find an index i such that both:
    (a) Finish[i] == false
    (b) Requesti ≤ 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] == false, for some i, 1 ≤ i ≤ n, then the system is in deadlock
   state. Moreover, if Finish[i] == false, then Pi is deadlocked.
Note:
The algorithm requires an order of O(m
  x n2) operations to detect whether
  the system is in deadlocked state.
Example of Detection Algorithm
 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
                ABC             ABC              ABC
         P0     010             000                        000
         P1     200             202
         P2     303             000
         P3     211             100
         P4     002             002
 Sequence <P0, P2, P3, P1, P4> will result in Finish[i] = true for
  all i. Therefore, no deadlock
Example (cont.)
 P2 requests an additional instance of type C.
               Request
               ABC
       P0      000
       P1      202
       P2      001
       P3      100
       P4      002
 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.
Detection Algorithm Usage
   When and how often, to invoke deadlock detection?

   Factors to consider:
     How often a deadlock is likely to occur
     How many process will need to be rolled back
   Approaches
     Execute the algorithm at predetermined time interval
     Execute the algorithm whenever a resource request cannot
      be granted immediatetly
Recovery from deadlock: Process
Termination
   Who’s responsibility?
     Inform the operator and let him deal with the
      deadlock manually
     Allow the system to recover from deadlock
      automatically.
Approaches: I. Process Termination

   Abort all deadlocked processes

   Abort one process at a time until the
    deadlock cycle is eliminated
In which order should we choose to abort?

 Priority of process
 How long process has computed and
  how much longer to completion
 Resources the process has used
 Resources process needs to complete
 How many process will need to be
  terminated?
 Is process interactive or batch?
II. Process preemption
 Selecting a victim – minimize cost
 Rollback – return to some safe state,
  restart process for that state.
 Starvation – same process may always
  be picked as victim, include number of
  rollback in cost factor
Quiz
 Consider the following and answer the questions that follow:
 P = P1, P2, P3, P4, P5
 R = R1, R2, R3, R4
 Instances: R1=2, R2=3, R3=1, R4=1
 E={ R3 -> P1, P1 -> R2, R2 -> P2, R2 -> P4, R1 -> P2, R1 -> P3,
     P4 -> R4}
 2 points each:
  Question 1: Is there a cycle? (Y/N)
  Question 2: Is there a deadlock? (Y/N)
  Question 3: Will P1’s request for R2 be granted? (Y/N)
  Question 4: Will P4’s request for R4 be granted? (Y/N)
  Question 5: How many available instances are there for R2?
Quiz
 8 processes P0 through P7; 4 resource types:
  A (10 instances), B (5), C (11) and D (6).
 Snapshot at time T0:
                 Allocation       Max
                 ABCD                    ABCD
       P0        0121             7492
       P1        2100             3220
       P2        0020             9072
       P3        2102             2243
       P4        0020             4363
       P5        2020             2132
       P6        2111             5221
       P7        1020             7485
Question 6: Is the system safe?
Question 7: If yes, what is the safe sequence? If no, what

Contenu connexe

Tendances

Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI Hanif Durad
 
Multiprocessor Architecture (Advanced computer architecture)
Multiprocessor Architecture  (Advanced computer architecture)Multiprocessor Architecture  (Advanced computer architecture)
Multiprocessor Architecture (Advanced computer architecture)vani261
 
Deadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbianDeadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbiansaad symbian
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)Ravinder Kamboj
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithmssathish sak
 
DBMS (Deadlock, deadlock prevention, 2phase locking)
DBMS (Deadlock, deadlock prevention, 2phase locking)DBMS (Deadlock, deadlock prevention, 2phase locking)
DBMS (Deadlock, deadlock prevention, 2phase locking)Gaurav Solanki
 
Introduction to distributed file systems
Introduction to distributed file systemsIntroduction to distributed file systems
Introduction to distributed file systemsViet-Trung TRAN
 
parallel programming models
 parallel programming models parallel programming models
parallel programming modelsSwetha S
 
Lecture 3 parallel programming platforms
Lecture 3   parallel programming platformsLecture 3   parallel programming platforms
Lecture 3 parallel programming platformsVajira Thambawita
 
Replication in Distributed Database
Replication in Distributed DatabaseReplication in Distributed Database
Replication in Distributed DatabaseAbhilasha Lahigude
 
Methods for handling deadlock
Methods for handling deadlockMethods for handling deadlock
Methods for handling deadlocksangrampatil81
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecturePankaj Kumar Jain
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidancewahab13
 
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...Gyanmanjari Institute Of Technology
 

Tendances (20)

Introduction to MPI
Introduction to MPI Introduction to MPI
Introduction to MPI
 
Multiprocessor Architecture (Advanced computer architecture)
Multiprocessor Architecture  (Advanced computer architecture)Multiprocessor Architecture  (Advanced computer architecture)
Multiprocessor Architecture (Advanced computer architecture)
 
Deadlock dbms
Deadlock dbmsDeadlock dbms
Deadlock dbms
 
Deadlocks2
Deadlocks2Deadlocks2
Deadlocks2
 
Bankers
BankersBankers
Bankers
 
Deadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbianDeadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbian
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
 
Operating Systems Process Scheduling Algorithms
Operating Systems   Process Scheduling AlgorithmsOperating Systems   Process Scheduling Algorithms
Operating Systems Process Scheduling Algorithms
 
DBMS (Deadlock, deadlock prevention, 2phase locking)
DBMS (Deadlock, deadlock prevention, 2phase locking)DBMS (Deadlock, deadlock prevention, 2phase locking)
DBMS (Deadlock, deadlock prevention, 2phase locking)
 
Introduction to distributed file systems
Introduction to distributed file systemsIntroduction to distributed file systems
Introduction to distributed file systems
 
parallel programming models
 parallel programming models parallel programming models
parallel programming models
 
Operating System: Deadlock
Operating System: DeadlockOperating System: Deadlock
Operating System: Deadlock
 
Lecture 3 parallel programming platforms
Lecture 3   parallel programming platformsLecture 3   parallel programming platforms
Lecture 3 parallel programming platforms
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
 
Replication in Distributed Database
Replication in Distributed DatabaseReplication in Distributed Database
Replication in Distributed Database
 
Methods for handling deadlock
Methods for handling deadlockMethods for handling deadlock
Methods for handling deadlock
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecture
 
Deadlock in database
Deadlock in databaseDeadlock in database
Deadlock in database
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidance
 
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
 

En vedette

RBM、Deep Learningと学習(全脳アーキテクチャ若手の会 第3回DL勉強会発表資料)
RBM、Deep Learningと学習(全脳アーキテクチャ若手の会 第3回DL勉強会発表資料)RBM、Deep Learningと学習(全脳アーキテクチャ若手の会 第3回DL勉強会発表資料)
RBM、Deep Learningと学習(全脳アーキテクチャ若手の会 第3回DL勉強会発表資料)Takuma Yagi
 
Women in Tech: How to Build A Human Company
Women in Tech: How to Build A Human CompanyWomen in Tech: How to Build A Human Company
Women in Tech: How to Build A Human CompanyLuminary Labs
 
JAISTサマースクール2016「脳を知るための理論」講義02 Synaptic Learning rules
JAISTサマースクール2016「脳を知るための理論」講義02 Synaptic Learning rulesJAISTサマースクール2016「脳を知るための理論」講義02 Synaptic Learning rules
JAISTサマースクール2016「脳を知るための理論」講義02 Synaptic Learning ruleshirokazutanaka
 
JAISTサマースクール2016「脳を知るための理論」講義04 Neural Networks and Neuroscience
JAISTサマースクール2016「脳を知るための理論」講義04 Neural Networks and Neuroscience JAISTサマースクール2016「脳を知るための理論」講義04 Neural Networks and Neuroscience
JAISTサマースクール2016「脳を知るための理論」講義04 Neural Networks and Neuroscience hirokazutanaka
 
Why dont you_create_new_spark_jl
Why dont you_create_new_spark_jlWhy dont you_create_new_spark_jl
Why dont you_create_new_spark_jlShintaro Fukushima
 
Probabilistic Graphical Models 輪読会 #1
Probabilistic Graphical Models 輪読会 #1Probabilistic Graphical Models 輪読会 #1
Probabilistic Graphical Models 輪読会 #1Takuma Yagi
 
最近のRのランダムフォレストパッケージ -ranger/Rborist-
最近のRのランダムフォレストパッケージ -ranger/Rborist-最近のRのランダムフォレストパッケージ -ranger/Rborist-
最近のRのランダムフォレストパッケージ -ranger/Rborist-Shintaro Fukushima
 
機械学習によるデータ分析 実践編
機械学習によるデータ分析 実践編機械学習によるデータ分析 実践編
機械学習によるデータ分析 実践編Ryota Kamoshida
 
Rユーザのためのspark入門
Rユーザのためのspark入門Rユーザのためのspark入門
Rユーザのためのspark入門Shintaro Fukushima
 
JAISTサマースクール2016「脳を知るための理論」講義03 Network Dynamics
JAISTサマースクール2016「脳を知るための理論」講義03 Network DynamicsJAISTサマースクール2016「脳を知るための理論」講義03 Network Dynamics
JAISTサマースクール2016「脳を知るための理論」講義03 Network Dynamicshirokazutanaka
 
論文紹介:Using the Forest to See the Trees: A Graphical. Model Relating Features,...
論文紹介:Using the Forest to See the Trees: A Graphical. Model Relating Features,...論文紹介:Using the Forest to See the Trees: A Graphical. Model Relating Features,...
論文紹介:Using the Forest to See the Trees: A Graphical. Model Relating Features,...Takuma Yagi
 
機械学習によるデータ分析まわりのお話
機械学習によるデータ分析まわりのお話機械学習によるデータ分析まわりのお話
機械学習によるデータ分析まわりのお話Ryota Kamoshida
 
What is the maker movement?
What is the maker movement?What is the maker movement?
What is the maker movement?Luminary Labs
 
The Human Company Playbook, Version 1.0
The Human Company Playbook, Version 1.0The Human Company Playbook, Version 1.0
The Human Company Playbook, Version 1.0Luminary Labs
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 

En vedette (20)

Kerberos
KerberosKerberos
Kerberos
 
RBM、Deep Learningと学習(全脳アーキテクチャ若手の会 第3回DL勉強会発表資料)
RBM、Deep Learningと学習(全脳アーキテクチャ若手の会 第3回DL勉強会発表資料)RBM、Deep Learningと学習(全脳アーキテクチャ若手の会 第3回DL勉強会発表資料)
RBM、Deep Learningと学習(全脳アーキテクチャ若手の会 第3回DL勉強会発表資料)
 
Women in Tech: How to Build A Human Company
Women in Tech: How to Build A Human CompanyWomen in Tech: How to Build A Human Company
Women in Tech: How to Build A Human Company
 
JAISTサマースクール2016「脳を知るための理論」講義02 Synaptic Learning rules
JAISTサマースクール2016「脳を知るための理論」講義02 Synaptic Learning rulesJAISTサマースクール2016「脳を知るための理論」講義02 Synaptic Learning rules
JAISTサマースクール2016「脳を知るための理論」講義02 Synaptic Learning rules
 
JAISTサマースクール2016「脳を知るための理論」講義04 Neural Networks and Neuroscience
JAISTサマースクール2016「脳を知るための理論」講義04 Neural Networks and Neuroscience JAISTサマースクール2016「脳を知るための理論」講義04 Neural Networks and Neuroscience
JAISTサマースクール2016「脳を知るための理論」講義04 Neural Networks and Neuroscience
 
Network security
Network securityNetwork security
Network security
 
強化学習勉強会・論文紹介(Kulkarni et al., 2016)
強化学習勉強会・論文紹介(Kulkarni et al., 2016)強化学習勉強会・論文紹介(Kulkarni et al., 2016)
強化学習勉強会・論文紹介(Kulkarni et al., 2016)
 
Why dont you_create_new_spark_jl
Why dont you_create_new_spark_jlWhy dont you_create_new_spark_jl
Why dont you_create_new_spark_jl
 
Probabilistic Graphical Models 輪読会 #1
Probabilistic Graphical Models 輪読会 #1Probabilistic Graphical Models 輪読会 #1
Probabilistic Graphical Models 輪読会 #1
 
KDD2016論文読み会資料(DeepIntent)
KDD2016論文読み会資料(DeepIntent) KDD2016論文読み会資料(DeepIntent)
KDD2016論文読み会資料(DeepIntent)
 
最近のRのランダムフォレストパッケージ -ranger/Rborist-
最近のRのランダムフォレストパッケージ -ranger/Rborist-最近のRのランダムフォレストパッケージ -ranger/Rborist-
最近のRのランダムフォレストパッケージ -ranger/Rborist-
 
機械学習によるデータ分析 実践編
機械学習によるデータ分析 実践編機械学習によるデータ分析 実践編
機械学習によるデータ分析 実践編
 
Rユーザのためのspark入門
Rユーザのためのspark入門Rユーザのためのspark入門
Rユーザのためのspark入門
 
JAISTサマースクール2016「脳を知るための理論」講義03 Network Dynamics
JAISTサマースクール2016「脳を知るための理論」講義03 Network DynamicsJAISTサマースクール2016「脳を知るための理論」講義03 Network Dynamics
JAISTサマースクール2016「脳を知るための理論」講義03 Network Dynamics
 
【強化学習】Montezuma's Revenge @ NIPS2016
【強化学習】Montezuma's Revenge @ NIPS2016【強化学習】Montezuma's Revenge @ NIPS2016
【強化学習】Montezuma's Revenge @ NIPS2016
 
論文紹介:Using the Forest to See the Trees: A Graphical. Model Relating Features,...
論文紹介:Using the Forest to See the Trees: A Graphical. Model Relating Features,...論文紹介:Using the Forest to See the Trees: A Graphical. Model Relating Features,...
論文紹介:Using the Forest to See the Trees: A Graphical. Model Relating Features,...
 
機械学習によるデータ分析まわりのお話
機械学習によるデータ分析まわりのお話機械学習によるデータ分析まわりのお話
機械学習によるデータ分析まわりのお話
 
What is the maker movement?
What is the maker movement?What is the maker movement?
What is the maker movement?
 
The Human Company Playbook, Version 1.0
The Human Company Playbook, Version 1.0The Human Company Playbook, Version 1.0
The Human Company Playbook, Version 1.0
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 

Similaire à Os module 2 d

Mch7 deadlock
Mch7 deadlockMch7 deadlock
Mch7 deadlockwahab13
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlockstech2click
 
Deadlocks prefinal
Deadlocks prefinalDeadlocks prefinal
Deadlocks prefinalmarangburu42
 
Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456marangburu42
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232marangburu42
 
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Wakil Kumar
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating SystemAUST
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemEktaVaswani2
 
Mca ii os u-3 dead lock & io systems
Mca  ii  os u-3 dead lock & io systemsMca  ii  os u-3 dead lock & io systems
Mca ii os u-3 dead lock & io systemsRai University
 
Module-2Deadlock.ppt
Module-2Deadlock.pptModule-2Deadlock.ppt
Module-2Deadlock.pptKAnurag2
 

Similaire à Os module 2 d (20)

Mch7 deadlock
Mch7 deadlockMch7 deadlock
Mch7 deadlock
 
deadlock in OS.pptx
deadlock in OS.pptxdeadlock in OS.pptx
deadlock in OS.pptx
 
Deadlock.ppt
Deadlock.pptDeadlock.ppt
Deadlock.ppt
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
 
10. deadlock
10. deadlock10. deadlock
10. deadlock
 
Module3
Module3Module3
Module3
 
Deadlocks prefinal
Deadlocks prefinalDeadlocks prefinal
Deadlocks prefinal
 
Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456
 
Gp1242 007 oer ppt
Gp1242 007 oer pptGp1242 007 oer ppt
Gp1242 007 oer ppt
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
OS 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
 
Mca ii os u-3 dead lock & io systems
Mca  ii  os u-3 dead lock & io systemsMca  ii  os u-3 dead lock & io systems
Mca ii os u-3 dead lock & io systems
 
Module-2Deadlock.ppt
Module-2Deadlock.pptModule-2Deadlock.ppt
Module-2Deadlock.ppt
 

Plus de Gichelle Amon (20)

Os module 2 c
Os module 2 cOs module 2 c
Os module 2 c
 
Image segmentation ppt
Image segmentation pptImage segmentation ppt
Image segmentation ppt
 
Lec3 final
Lec3 finalLec3 final
Lec3 final
 
Lec 3
Lec 3Lec 3
Lec 3
 
Lec2 final
Lec2 finalLec2 final
Lec2 final
 
Lec 4
Lec 4Lec 4
Lec 4
 
Lec1 final
Lec1 finalLec1 final
Lec1 final
 
Module 3 law of contracts
Module 3  law of contractsModule 3  law of contracts
Module 3 law of contracts
 
Transport triggered architecture
Transport triggered architectureTransport triggered architecture
Transport triggered architecture
 
Time triggered arch.
Time triggered arch.Time triggered arch.
Time triggered arch.
 
Subnetting
SubnettingSubnetting
Subnetting
 
Os module 2 c
Os module 2 cOs module 2 c
Os module 2 c
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
 
Lec5
Lec5Lec5
Lec5
 
Delivery
DeliveryDelivery
Delivery
 
Addressing
AddressingAddressing
Addressing
 
6 spatial filtering p2
6 spatial filtering p26 spatial filtering p2
6 spatial filtering p2
 
5 spatial filtering p1
5 spatial filtering p15 spatial filtering p1
5 spatial filtering p1
 
Medical image analysis
Medical image analysisMedical image analysis
Medical image analysis
 
Presentation2
Presentation2Presentation2
Presentation2
 

Dernier

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Dernier (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Os module 2 d

  • 2. Objectives  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.
  • 3. Deadlock  Defined as the permanent blocking of a set of processes that compete for a system resource, including database records and communication lines  A situation wherein each of a collection of processes is waiting for something from other processes in the collection. Since all are waiting, none can provide any of the things being waited for.
  • 4. Deadlock  A situation wherein a process is requesting a resource which is withheld by another process and never get hold of the resource.
  • 5. Example  System has 2 tape drives  P1 and P2 each hold one tape drive and each needs another one.  Semaphores A and B initialized to 1  P0 P1  Wait(A); Wait(B);  Wait(B); Wait(A);
  • 6. Deadlock  Deadlock occurs when a set of processes are in a wait state, because each process is waiting for a resource that is held by some other waiting process. Therefore, all deadlocks involve conflicting resource that are needed by two or more processes.
  • 7. 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).  Several cars may have to be backed up if a deadlock occurs.  Starvation is possible.
  • 8. Deadlock  Unlike some other problems in multiprogramming systems, there is no efficient solution to the deadlock problem in the general case. It is one area where there is a strong theory but it is completely ignored in practice because solutions to deadlock are expensive.
  • 9. Resource  A hardware device (e.g. tape drive, memory)  A piece of information (e.g. a locked record in a database)
  • 10. General Categories of Resources  Reusable – something that can be safely used by one process at a time and is not depleted by that use. Processes obtain resources that they later release for reuse by others.  Example:  CPU, Memory, specific I/O devices or files.
  • 11. General Categories of Resources  Consumable – these can be created and destroyed. When a resource is acquired by a process, the resource ceases to exist.  Examples:  Interrupts, signals, messages.
  • 12. Types of Resources  Preemptable resource – a resource that can be taken away from the process owning it with no ill effect (needs save/restore)  Example: Memory or CPU
  • 13. Types of Resources  Non-preemptable – a resource that cannot be taken away from its current owner without causing the computation to fail.  Example: Printer or floppy disk.
  • 14. Note  Deadlocks occur when sharing reusable and non-preemptable resources
  • 15. Pop Exercise  Classify the following as either sharable or non-sharable  A. Hard disk  B. file  C. keyboard
  • 16. System Model  System consists of a finite number of resources and a finite number of processes competing for resources.  Resources are partitioned into several types, each of which consists of some number of identical instances
  • 17. System Model  When a process requests an instance of a resource type, the allocation of any instance of the type will satisfy the request (otherwise, resource types have not been defined properly).
  • 18. Protocol for resource utilization  Request – the process will request for a certain resource. If the request cannot be granted immediately, then the requesting process must wait until it can acquire the resource.  Use – the process can operate the resource  Release – the process relinquishes the resources.
  • 19. Note  A set of processes is deadlocked when every process in the set is waiting for an event that can be caused only by another process in the set.
  • 20. Deadlock Characterization Deadlock can arise if four conditions hold simultaneously:  Mutual exclusion: only one process at a time can use a resource.  Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes.  No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task.  Circular wait: there exists a set {P0, P1, …, P0} 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 P0 is waiting for a resource that is held by P0.
  • 21. Additional characteristic  PROCESS IRREVERSIBLE – Unable to reset to an earlier state where resources are not held.
  • 22. Systems avoiding deadlocks  Systems involving only shared resources cannot deadlock. – negates mutual exclusion  System that aborts processes which is requesting a resource but currently being used. – negates hold and wait  Preemption may be possible if a process does not use its resources until it has acquired all it needs – negates no preemption
  • 23. Systems…  Transaction processing systems provide checkpoints so that processes may back out of a transaction. – negates irreversible process  System that detects or avoids deadlocks – prevents cycle.
  • 24. Resource-Allocation Graph (RAG)  Consists of a set of vertices V and a set of edges E. Devised by Holt in 1972.  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 P1 → Rj  assignment edge – directed edge Rj → Pi
  • 25. Resource-Allocation Graph (RAG)  Process  Resource Type with 4 instances  Pi requests instance of Rj Pi Rj  Pi is holding an instance of Rj Pi Rj
  • 26. Example  P = P1, P2, P3  R = R1, R2, R3, R4  Instances: R1=1, R2=2, R3=1, R4=3  E={ P1 -> R1, P2 -> R3, R1 -> P2, R2 -> P1, R2 -> P2, R3 -> P3,  Question: is there a deadlock?
  • 28. Resource Allocation Graph With A Deadlock
  • 29. Graph With A Cycle But No Deadlock
  • 30. 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.
  • 31. Methods for handling deadlocks  3 strategies: 1. Ostrich Solution: Ignore the problem and pretend deadlocks never occur in the system. Used by most OS, including Unix
  • 32. Methods for handling deadlocks 2. Ensure that the system will never enter a deadlock state.  Deadlock prevention – Design a system in such a way that the 4 conditions leading to deadlock will never occur.  Deadlock avoidance – make a decision dynamically checking whether the request will, if granted, potentially lead to a deadlock or not.
  • 33. Methods for handling deadlocks 3. Allow the system to enter a deadlock state and recover  Deadlock detection and recovery
  • 34. Deadlock Prevention  Preventing the occurrence of one of the necessary conditions leading to deadlock. Deadlock prevention strategy is very conservative. It solves the problem of deadlock by limiting access to resources and by imposing restrictions on processes.
  • 35. Mutual Exclusion  In general, this condition cannot be required for non-sharable resources but is a must for sharable resources.
  • 36. Hold and Wait  Must guarantee that whenever a process requests a resource, it does not hold any other resources. A process is blocked until all requests can be granted simultaneously.  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.  Low resource utilization; starvation possible
  • 37. No preemption  If a process that is holding some resource 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 new ones that it is requesting.
  • 38. Circular Wait  Impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration.
  • 39. 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.
  • 40. Ways to avoid deadlock by careful resource allocation 1. Resource trajectories 2. Safe/Unsafe states 3. Dijkstra’s Banker’s Algorithm
  • 41. 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.
  • 42. Safe, Unsafe , Deadlock State
  • 43. Avoidance algorithms  Single instance of a resource type. Use a resource-allocation graph  Multiple instances of a resource type. Use the banker’s algorithm
  • 44. Resource-Allocation Graph Scheme  Claim edge Pi → Rj indicated that process Pj may request resource Rj; represented by a dashed line.  Claim edge converts to request edge when a process requests a resource.  Request edge converted to an assignment edge when the resource is allocated to the process.  When a resource is released by a process, assignment edge reconverts to a claim edge.  Resources must be claimed a priori in the system.
  • 46. Unsafe State In Resource-Allocation Graph
  • 47. Sample Algorithm  Given the RAG of the system (Initially on a safe state, grant a resource allocation request if and only if doing so will not introduce a cycle in the graph. (taking into consideration all assignment, request and claim edges). Otherwise, the requesting process has to wait.
  • 48. Sample Algorithm 1. Operation: P2 requests R3 Action: Request granted System State: SAFE 2. Operation: P3 requests R2 Action: REQUEST DENIED!!! System State: Leads to deadlock
  • 49. Sample 2  Consider a system with 15 identical instances of a resource Process Max Need Curr Allo Remaining P0 14 5 P1 10 5 P2 3 2  Currently available resource: 15 – (5+5+2) = 3  Is it safe?  Yes with a safe sequence of <P2, P1, P0>  What if P0 requests two more resources, will it be granted?  No, OS cannot satisfy remaining needs of all processes. Unsafe.
  • 50. Sample 3  Total instances: 8 Process Max Need Curr Allo Remaining P0 5 3 P1 8 1 P2 7 2  Is it safe or unsafe? What is the safe sequence?
  • 51. Sample 4  Total instances: 8 Process Max Need Curr Allo Remaining P0 5 3 P1 8 1 P2 7 2  Is it safe or unsafe? What is the safe sequence?
  • 52. Banker’s Algorithm  Multiple instances.  Each process must a priori claim maximum use.  When a process requests a resource it may have to wait.  When a process gets all its resources it must return them in a finite amount of time.
  • 53. Data Structures for the Banker’s Algorithm  Let n = number of processes, and m = number of resources types.  Available: Vector of length m. If available [j] = k, there are k instances of resource type Rj available.  Max: n x m matrix. If Max [i,j] = k, then process Pi may request at most k instances of resource type Rj.  Allocation: n x m matrix. If Allocation[i,j] = k then Pi is currently allocated k instances of Rj  .  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].
  • 54. 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 and 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.
  • 55. Example of Banker’s Algorithm  5 processes P0 through P4; 3 resource types: A (10 instances), B (5instances), and C (7 instances).  Snapshot at time T0: Allocation Max Available ABC ABC ABC P0 010 753 332 P1 200 322 P2 302 902 P3 211 222 P4 002 433
  • 56. Example (Cont.)  The content of the matrix Need is defined to be Max – Allocation. Need ABC P0 743 P1 122 P2 600 P3 011 P4 431  The system is in a safe state since the sequence < P1, P3, P4, P2, P0> satisfies safety criteria.
  • 57. Example: P1 Request (1,0,2)  Check that Request ≤ Available (that is, (1,0,2) ≤ (3,3,2) ⇒ true. Allocation Need Available ABC ABC ABC P0 010 743 230 P1 302 020 P2 302 600 P3 211 011 P4 002 431  Executing safety algorithm shows that sequence < P1, P3, P4, P0, P2> satisfies safety requirement.  Can request for (3,3,0) by P4 be granted?  Can request for (0,2,0) by P0 be granted?
  • 58. Deadlock detection and recovery  Implies no conscious effort to prevent/avoid deadlocks  At certain times during processing, the system executes an algorithm to determine whether or not a deadlock has occurred.  If so, an attempt to recover from the deadlock is made.
  • 59. Detection Algorithm Single Instance of Each Resource Type  Maintain wait-for graph  Nodes are processes.  Pi → Pj if Pi is waiting for Pj.  Periodically invoke an algorithm that searches for a cycle in the graph. If there is a cycle, there exists a deadlock.  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.
  • 60. Resource-Allocation Graph and Wait-for Graph Resource-Allocation Graph Corresponding wait-for graph
  • 61. Several Instances of a Resource Type  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 [ij] = k, then process Pi is requesting k more instances of resource type. Rj.
  • 62. Detection Algorithm 1. Let Work and Finish be vectors of length m and n, respectively Initialize: (a) Work = Available n For i = 1,2, …, n, if Allocationi ≠ 0, then Finish[i] = false;otherwise, Finish[i] = true. 2. Find an index i such that both: (a) Finish[i] == false (b) Requesti ≤ 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] == false, for some i, 1 ≤ i ≤ n, then the system is in deadlock state. Moreover, if Finish[i] == false, then Pi is deadlocked.
  • 63. Note: The algorithm requires an order of O(m x n2) operations to detect whether the system is in deadlocked state.
  • 64. Example of Detection Algorithm  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 ABC ABC ABC P0 010 000 000 P1 200 202 P2 303 000 P3 211 100 P4 002 002  Sequence <P0, P2, P3, P1, P4> will result in Finish[i] = true for all i. Therefore, no deadlock
  • 65. Example (cont.)  P2 requests an additional instance of type C. Request ABC P0 000 P1 202 P2 001 P3 100 P4 002  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.
  • 66. Detection Algorithm Usage  When and how often, to invoke deadlock detection?  Factors to consider:  How often a deadlock is likely to occur  How many process will need to be rolled back  Approaches  Execute the algorithm at predetermined time interval  Execute the algorithm whenever a resource request cannot be granted immediatetly
  • 67. Recovery from deadlock: Process Termination  Who’s responsibility?  Inform the operator and let him deal with the deadlock manually  Allow the system to recover from deadlock automatically.
  • 68. Approaches: I. Process Termination  Abort all deadlocked processes  Abort one process at a time until the deadlock cycle is eliminated
  • 69. In which order should we choose to abort?  Priority of process  How long process has computed and how much longer to completion  Resources the process has used  Resources process needs to complete  How many process will need to be terminated?  Is process interactive or batch?
  • 70. II. Process preemption  Selecting a victim – minimize cost  Rollback – return to some safe state, restart process for that state.  Starvation – same process may always be picked as victim, include number of rollback in cost factor
  • 71. Quiz Consider the following and answer the questions that follow: P = P1, P2, P3, P4, P5 R = R1, R2, R3, R4 Instances: R1=2, R2=3, R3=1, R4=1 E={ R3 -> P1, P1 -> R2, R2 -> P2, R2 -> P4, R1 -> P2, R1 -> P3, P4 -> R4} 2 points each:  Question 1: Is there a cycle? (Y/N)  Question 2: Is there a deadlock? (Y/N)  Question 3: Will P1’s request for R2 be granted? (Y/N)  Question 4: Will P4’s request for R4 be granted? (Y/N)  Question 5: How many available instances are there for R2?
  • 72. Quiz  8 processes P0 through P7; 4 resource types: A (10 instances), B (5), C (11) and D (6).  Snapshot at time T0: Allocation Max ABCD ABCD P0 0121 7492 P1 2100 3220 P2 0020 9072 P3 2102 2243 P4 0020 4363 P5 2020 2132 P6 2111 5221 P7 1020 7485 Question 6: Is the system safe? Question 7: If yes, what is the safe sequence? If no, what