λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
⭐ Group_Study/Operating System

[4μ£Όμ°¨] Deadlock: Deadlock Avoidance

by ν¬μŠ€νŠΈμ‰μ΄ν¬ 2022. 12. 27.

Deadlock: Deadlock Avoidance

Deadlock Avoidance: κ°œμš”

βœ” μ‹œμŠ€ν…œμ˜ μƒνƒœλ₯Ό 계속 κ°μ‹œ

βœ” μ‹œμŠ€ν…œμ΄ deadlock μƒνƒœκ°€ 될 κ°€λŠ₯성이 μžˆλŠ” μžμ› ν• λ‹Ή μš”μ²­ 보λ₯˜

βœ” μ‹œμŠ€ν…œμ„ 항상 safe state둜 μœ μ§€

Safe State

βœ” Safe state

  • λͺ¨λ“  ν”„λ‘œμ„ΈμŠ€κ°€ 정상적 μ’…λ£Œ κ°€λŠ₯ν•œ μƒνƒœ
  • Safe sequenceκ°€ 쑴재
    • Deadlock μƒνƒœκ°€ λ˜μ§€ μ•Šμ„ 수 μžˆμŒμ„ 보μž₯

βœ” Unsafe state

  • Deadlock μƒνƒœκ°€ 될 κ°€λŠ₯성이 있음
  • λ°˜λ“œμ‹œ λ°œμƒν•œλ‹€λŠ” μ˜λ―ΈλŠ” μ•„λ‹ˆλ‹€

κ°€μ •

βœ” ν”„λ‘œμ„ΈμŠ€μ˜ μˆ˜κ°€ 고정됨
βœ” μžμ›μ˜ μ’…λ₯˜μ™€ μˆ˜κ°€ 고정됨
βœ” ν”„λ‘œμ„ΈμŠ€κ°€ μš”κ΅¬ν•˜λŠ” μžμ› 및 μ΅œλŒ€ μˆ˜λŸ‰μ„ μ•Œκ³  있음
βœ” ν”„λ‘œμ„ΈμŠ€λŠ” μžμ›μ„ μ‚¬μš© ν›„ λ°˜λ“œμ‹œ λ°˜λ‚©

βœ” Not practical

Algorithms

  1. Dijkstra's algorithm (Banker's algorithm)
  2. Habermann's algorithm

Dijkstar's Banker's algorithm

βœ” Deadlock avoidanceλ₯Ό μœ„ν•œ κ°„λ‹¨ν•œ 이둠적 기법

βœ” κ°€μ •: ν•œ μ’…λ₯˜μ˜ μžμ›μ΄ μ—¬λŸ¬ 개

βœ” μ‹œμŠ€ν…œμ„ 항상 safe state둜 μœ μ§€

βœ” 1 resource type R, 10 resource units, 3 processes

safe state example

unsafe state example


βœ” μžμ› μš”μ²­ 이후에도 safe stateκ°€ μœ μ§€λ  수 있으면 μš”μ²­ μŠΉλ‚™

βœ” μžμ› μš”μ²­ 이후에 unsafe stateκ°€ 되면 μš”μ²­ 거절

Habermann's algorithms

βœ” Dijkstar's algorithm의 ν™•μž₯
βœ” μ—¬λŸ¬ μ’…λ₯˜μ˜ μžμ› κ³ λ €

  • Multiple resource types
  • Multiple resource units for each resource type

βœ” μ‹œμŠ€ν…œμ„ 항상 safe state둜 μœ μ§€

Example

βœ” 3 types of resource: $R_a, R_b, R_c$
βœ” Number of resouce units for each type: (10, 5, 7)
βœ” 5 processes


βœ” Dijkstra's algorithmκ³Ό κΈ°λ³Έ μ›λ¦¬λŠ” λ™μΌν•˜λ‹€ (safe -> accept / unsafe -> reject)

Deadlock Avoidance 정리

βœ” Deadlock의 λ°œμƒμ„ 막을 수 있음

βœ” High overhead

  • μ‹œμŠ€ν…œμ„ 항상 κ°μ‹œν•˜κ³  μžˆμ–΄μ•Ό ν•œλ‹€

βœ” Low resource utilization

  • Safe state μœ μ§€λ₯Ό μœ„ν•΄, μ‚¬μš© λ˜μ§€ μ•ŠλŠ” μžμ›μ΄ 쑴재

βœ” Not practical

  • λΉ„ν˜„μ‹€μ  κ°€μ •
    • ν”„λ‘œμ„ΈμŠ€ 수, μžμ› μˆ˜κ°€ κ³ μ •
    • ν•„μš”ν•œ μ΅œλŒ€ μžμ› 수λ₯Ό μ•Œκ³  있음

λŒ“κΈ€