Login Required

This note requires login to view the full content (95 lines total). Showing first 20 lines as preview. Please login to view the full content.

Login to unlock

Chapter 7: Deadlocks

Created: 2025-12-16
Updated: 2025-12-16
  • Necessary Conditions for Deadlock
    1. Mutual Exclusion: exist a resource that only can be used by one process at a time
    2. Hold and Wait: a process holding some resources and is waiting for another resource
    3. No Preemption: a resource can only be released voluntarily
    4. Circular Wait: a set of processes are waiting for each other in a circular chain
  • System Model
    • resources types: R1,R2,...,RmR_1, R_2, ..., R_m (e.g. CPU, memory, IO devices)
    • each resource type RiR_i has WiW_i instances (e.g. a computer has 2 CPUs)
    • each process: request → use → release
  • Resource-Allocation Graph
    • a directed graph with processes and resources as nodes
    • PiRjP_i \to R_j edge: PiP_i requests RjR_j
    • RjPiR_j \to P_i edge: RjR_j is allocated to PiP_i
    • if the graph contains no cycles → no deadlock
    • if the graph contains a cycle
      • only one instance per resource type → deadlock
      • multiple instances per resource type → may or may not be deadlock OS-ch7-ResourceAllocationGraph.png

Login to unlock full content

Login Now