Deadlock - hochan222/Everything-in-JavaScript GitHub Wiki

๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ”๋กœ๊ฐ€๊ธฐ

  • Deadlock
    • ์ผ๋ จ์˜ ํ”„๋กœ์„ธ์Šค๋“ค์ด ์„œ๋กœ๊ฐ€ ๊ฐ€์ง„ ์ž์›์„ ๊ธฐ๋‹ค๋ฆฌ๋ฉฐ block๋œ ์ƒํƒœ
  • Resource (์ž์›)
    • ํ•˜๋“œ์›จ์–ด, ์†Œํ”„ํŠธ์›จ์–ด ๋“ฑ์„ ํฌํ•จํ•˜๋Š” ๊ฐœ๋…
    • I/O device, CPU cycle, memory space, semaphore
    • ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ž์›์„ ์‚ฌ์šฉํ•˜๋Š” ์ ˆ์ฐจ
      • Request, Allocate, Use, Release

Deadlock ๋ฐœ์ƒ์˜ 4๊ฐ€์ง€ ์กฐ๊ฑด

  • Mutual exclusion (์ƒํ˜ธ ๋ฐฐ์ œ)
    • ๋งค ์ˆœ๊ฐ„ ํ•˜๋‚˜์˜ ํ”„๋กœ์„ธ์Šค๋งŒ์ด ์ž์›์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ
  • No preemption (๋น„์„ ์ )
    • ํ”„๋กœ์„ธ์Šค๋Š” ์ž์›์„ ์Šค์Šค๋กœ ๋‚ด์–ด ๋†“์„ ๋ฟ ๊ฐ•์ œ๋กœ ๋นผ์•—๊ธฐ์ง€ ์•Š์Œ
  • Hold and wait (๋ณด์œ  ๋Œ€๊ธฐ)
    • ์ž์›์„ ๊ฐ€์ง„ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋‹ค๋ฅธ ์ž์›์„ ๊ธฐ๋‹ค๋ฆด ๋•Œ ๋ณด์œ  ์ž์›์„ ๋†“์ง€ ์•Š๊ณ  ๊ณ„์† ๊ฐ€์ง€๊ณ  ์žˆ์Œ
    • ์ž์› ๊ฐ€์ง€๊ณ ์žˆ๋Š”๋ฐ ์ƒˆ๋กœ์šด ์ž์› ์š”๊ตฌํ•  ๋•Œ
  • Circular wait (์ˆœํ™˜ ๋Œ€๊ธฐ)
    • ์ž์›์„ ๊ธฐ๋‹ค๋ฆฌ๋Š” ํ”„๋กœ์„ธ์Šค๊ฐ„์— ์‚ฌ์ดํด์ด ํ˜•์„ฑ๋˜์–ด์•ผ ํ•จ

resource-Allocation Graph

Deadlock์˜ ์ฒ˜๋ฆฌ ๋ฐฉ๋ฒ•

  • Deadlock Prevention
    • ์ž์› ํ• ๋‹น ์‹œ Deadlock์˜ 4์‚ฌ์ง€ ํ•„์š” ์กฐ๊ฑด ์ค‘ ์–ด๋Š ํ•˜๋‚˜๊ฐ€ ๋งŒ์กฑ๋˜์ง€ ์•Š๋„๋ก ํ•˜๋Š” ๊ฒƒ
    • Utilization ์ €ํ•˜, throughput ๊ฐ์†Œ, starvation ๋ฌธ์ œ
  • Deadlock Avoidance
    • ์ž์› ์š”์ฒญ์— ๋Œ€ํ•œ ๋ถ€๊ฐ€์ ์ธ ์ •๋ณด๋ฅผ ์ด์šฉํ•ด์„œ deadlock์˜ ๊ฐ€๋Šฅ์„ฑ์ด ์—†๋Š” ๊ฒฝ์šฐ์—๋งŒ ์ž์›์„ ํ• ๋‹น
    • ์‹œ์Šคํ…œ state๊ฐ€ ์›๋ž˜ state๋กœ ๋Œ์•„์˜ฌ ์ˆ˜ ์žˆ๋Š” ๊ฒฝ์šฐ์—๋งŒ ์ž์› ํ• ๋‹น
    • Banker's Algorithm
    • ํ”„๋กœ์„ธ์Šค์˜ ์ตœ๋Œ€ ์š”์ฒญ์œผ๋กœ ๊ณ ๋ คํ•ด์„œ ๊ณ„์‚ฐ.
  • Deadlock Detection and recovery
    • Deadlock ๋ฐœ์ƒ์€ ํ—ˆ์šฉํ•˜๋˜ ๊ทธ์— ๋Œ€ํ•œ detection ๋ฃจํ‹ด์„ ๋‘์–ด deadlock ๋ฐœ๊ฒฌ ์‹œ recover
  • Deadlock Ignorance (ํ˜„๋Œ€ ์šด์˜์ฒด์ œ ๋Œ€๋ถ€๋ถ„ ์ฑ„ํƒ, ์‚ฌ๋žŒ์—๊ฒŒ ๋งก๊น€)
    • Deadlock์„ ์‹œ์Šคํ…œ์ด ์ฑ…์ž„์ง€์ง€ ์•Š์Œ
    • UNIX๋ฅผ ํฌํ•จํ•œ ๋Œ€๋ถ€๋ถ„์˜ OS๊ฐ€ ์ฑ„ํƒ
    • Deadlock์ด ๋งค์šฐ ๋“œ๋ฌผ๊ฒŒ ๋ฐœ์ƒํ•˜๋ฏ€๋กœ deadlock์— ๋Œ€ํ•œ ์กฐ์น˜ ์ž์ฒด๊ฐ€ ๋” ํฐ overhead์ผ ์ˆ˜ ์žˆ์Œ