[210627 TIL] OS

Choi Rimยท2021๋…„ 6์›” 27์ผ
0

Way to developer

๋ชฉ๋ก ๋ณด๊ธฐ
8/21
post-thumbnail

Process Scheduling

SPN, SRTN, HRRN

SPN (Shortest-Process-Next)

  • Non-preemptive scheduling
  • ์Šค์ผ€์ค„๋ง ๊ธฐ์ค€ (Criteria)
    • ์‹คํ–‰์‹œ๊ฐ„ (burst time ๊ธฐ์ค€)
    • Burst time์ด ๊ฐ€์žฅ ์ž‘์€ ํ”„๋กœ์„ธ์Šค๋ฅผ ๋จผ์ € ์ฒ˜๋ฆฌ
      • SJF(Shortest Job First) scheduling
  • ์žฅ์ 
    • ํ‰๊ท  ๋Œ€๊ธฐ์‹œ๊ฐ„(Waiting Time, WT) ์ตœ์†Œํ™”
    • ์‹œ์Šคํ…œ ๋‚ด ํ”„๋กœ์„ธ์Šค ์ˆ˜ ์ตœ์†Œํ™”
      • ์Šค์ผ€์ค„๋ง ๋ถ€ํ•˜ ๊ฐ์†Œ, ๋ฉ”๋ชจ๋ฆฌ ์ ˆ์•ฝ -> ์‹œ์Šคํ…œ ํšจ์œจ ํ–ฅ์ƒ
    • ๋งŽ์€ ํ”„๋กœ์„ธ์Šค๋“ค์—๊ฒŒ ๋น ๋ฅธ ์‘๋‹ต ์‹œ๊ฐ„ ์ œ๊ณต
  • ๋‹จ์ 
    • Starvation (๊ธฐ์•„ํ˜„์ƒ, ๋ฌดํ•œ๋Œ€๊ธฐ) ํ˜„์ƒ ๋ฐœ์ƒ
      • BT(Burst Time)๊ฐ€ ๊ธด ํ”„๋กœ์„ธ์Šค๋Š” ์ž์›์„ ํ• ๋‹น ๋ฐ›์ง€ ๋ชป ํ•  ์ˆ˜ ์žˆ์Œ
        • Aging ๋“ฑ์œผ๋กœ ํ•ด๊ฒฐ (e.g HRRN)
      • ์ •ํ™•ํ•œ ์‹คํ–‰์‹œ๊ฐ„์„ ์•Œ ์ˆ˜ ์—†์Œ
        • ์‹คํ–‰์‹œ๊ฐ„ ์˜ˆ์ธก ๊ธฐ๋ฒ•์ด ํ•„์š”
    ์‚ฌ์ง„ ์ถœ์ฒ˜ - https://youtu.be/keY9Wi7scEs
  • ๋„์ฐฉํ•œ ํ”„๋กœ์„ธ์Šค๋“ค ์ค‘ Burst Time์ด ์งง์€ ํ”„๋กœ์„ธ์Šค ๋ถ€ํ„ฐ ์‹คํ–‰๋œ๋‹ค.
  • ํ”„๋กœ์„ธ์Šค 2๋Š” BT์ด ๊ธธ์–ด WT์ด ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค์— ๋น„ํ•ด ๊ธธ์–ด์ง„๋‹ค.

SRTN (Shortest Remaining Time Next)

  • SPN์˜ ๋ณ€ํ˜•
  • Preemptive scheduling
    • ์ž”์—ฌ ์‹คํ–‰ ์‹œ๊ฐ„์ด ๋” ์ ์€ ํ”„๋กœ์„ธ์Šค๊ฐ€ ready ์ƒํƒœ๊ฐ€ ๋˜๋ฉด ์„ ์ ๋จ
  • ์žฅ์ 
    • SPN์˜ ์žฅ์  ๊ทน๋Œ€ํ™”
  • ๋‹จ์ 
    • ํ”„๋กœ์„ธ์Šค ์ƒ์„ฑ์‹œ, ์ด ์‹คํ–‰ ์‹œ๊ฐ„ ์˜ˆ์ธก์ด ํ•„์š”ํ•จ
    • ์ž”์—ฌ ์‹คํ–‰์„ ๊ณ„์† ์ถ”์ ํ•ด์•ผ ํ•จ = overhead
    • Context switching overhead

-> ๊ตฌํ˜„ ๋ฐ ์‚ฌ์šฉ์ด ๋น„ํ˜„์‹ค์ 

HRRN (High-Response-Ratio-Next)

  • SPN์˜ ๋ณ€ํ˜•
    • SPN์˜ ๋‹จ์ ์ธ Starvation ๋ณด์™„
    • SPN + Aging concepts, None-preemptive scheduling
  • Aging concepts
    • ๋น„์œ ์ ์ธ ํ‘œํ˜„
      ๋…ธ์•ฝ์ž ๋ฐฐ๋ ค
    • ํ”„๋กœ์„ธ์Šค์˜ ๋Œ€๊ธฐ ์‹œ๊ฐ„(WT)์„ ๊ณ ๋ คํ•˜์—ฌ ๊ธฐํšŒ๋ฅผ ์ œ๊ณต
  • ์Šค์ผ€์ค„๋ง ๊ธฐ์ค€ (Criteria)
    • Response ratio๊ฐ€ ๋†’์€ ํ”„๋กœ์„ธ์Šค ์šฐ์„ 
  • Response ratio = WT+BT / BT (์‘๋‹ต๋ฅ )
    • SPN์˜ ์žฅ์  + Starvation ๋ฐฉ์ง€
    • ์‹คํ–‰ ์‹œ๊ฐ„ ์˜ˆ์ธก ๊ธฐ๋ฒ• ํ•„์š” (overhead)

Basic Scheduling algorithms

  • Fairness (๊ณตํ‰์„ฑ)
    • FCFS (First-Come-First-Service)
    • RR (Round-Roin)
  • Efficiency/Performance (ํšจ์œจ์„ฑ, ์„ฑ๋Šฅ)
    • SPN (Shortest-Proess-Next)
    • SRTN (Shortest Remaining Time Next)
    • HRRN (High-Response-Ratio-Next)

    ๋ฌธ์ œ์ 

    • ์‹คํ–‰์‹œ๊ฐ„ ์˜ˆ์ธก ๋ถ€ํ•˜

    ๋ฌธ์ œ์ ์„ ํ•ด๊ฒฐํ•œ algorithms

  • Efficiency/Performance (ํšจ์œจ์„ฑ, ์„ฑ๋Šฅ)
    • MLQ (Multi-level Queue)
    • MFQ (Multi-level Feedback Queue)

MLQ, MFQ

MLQ (Multi-level Queue)

  • ์ž‘์—… (or ์šฐ์„ ์ˆœ์œ„)๋ณ„ ๋ณ„๋„์˜ ready queue๋ฅผ ๊ฐ€์ง
    • ์—ฌ๋Ÿฌ๊ฐœ์˜ ready queue๋ฅผ ๊ฐ€์ง
    • ์ตœ์ดˆ ๋ฐฐ์ • ๋œ queue๋ฅผ ๋ฒ—์–ด๋‚˜์ง€ ๋ชปํ•จ
    • ๊ฐ๊ฐ์˜ queue๋Š” ์ž์‹ ๋งŒ์˜ ์Šค์ผ€์ค„๋ง ๊ธฐ๋ฒ• ์‚ฌ์šฉ
  • Queue ์‚ฌ์ด์—๋Š” ์šฐ์„ ์ˆœ์œ„ ๊ธฐ๋ฐ˜์˜ ์Šค์ผ€์ค„๋ง ์‚ฌ์šฉ
    • E.g., fixed-priority preemptive scheduling
  • ์žฅ์ 
    • ๋น ๋ฅธ ์‘๋‹ต์‹œ๊ฐ„
  • ๋‹จ์ 
    • ์—ฌ๋Ÿฌ ๊ฐœ์˜ Queue ๊ด€๋ฆฌ ๋“ฑ ์Šค์ผ€์ค„๋ง overhead
    • ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋‚ฎ์€ queue๋Š” starvation ํ˜„์ƒ ๋ฐœ์ƒ ๊ฐ€๋Šฅ

์‚ฌ์ง„ ์ถœ์ฒ˜ - https://youtu.be/actKUqea6Xc

  • Queue๊ฐ€ ์—ฌ๋Ÿฌ ๊ฐœ์ด๋ฉฐ ์œ„๋กœ ์˜ฌ๋ผ๊ฐˆ์ˆ˜๋ก ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋†’์•„์ง„๋‹ค.

MFQ (Multi-level Feedback Queue)

  • ํ”„๋กœ์„ธ์Šค์˜ Queue๊ฐ„ ์ด๋™์ด ํ—ˆ์šฉ๋œ MLQ
  • Feedback์„ ํ†ตํ•ด ์šฐ์„  ์ˆœ์œ„ ์กฐ์ •
    • ํ˜„์žฌ๊นŒ์ง€์˜ ํ”„๋กœ์„ธ์„œ ์‚ฌ์šฉ ์ •๋ณด(ํŒจํ„ด) ํ™œ์šฉ
  • ํŠน์„ฑ
    • ๋™์  ์šฐ์„ ์ˆœ์œ„ (Dynamic priority)
    • ์„ ์  ์Šค์ผ€์ค„๋ง (Preemptive scheduling)
    • Favor short burst-time processes
    • Favor I/O bounded processes
    • Improve adaptability
  • ํ”„๋กœ์„ธ์Šค์— ๋Œ€ํ•œ ์‚ฌ์ „ ์ •๋ณด ์—†์ด SRN, SRTN, HRRN ๊ธฐ๋ฒ•์˜ ํšจ๊ณผ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์Œ

์‚ฌ์ง„ ์ถœ์ฒ˜ - https://youtu.be/actKUqea6Xc

  • ํ๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ ์กด์žฌํ•˜๋ฉฐ ํ๋“ค ๊ฐ„์— ์ด๋™์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
  • ๋‹จ์ 
    • ์„ค๊ณ„ ๋ฐ ๊ตฌํ˜„์ด ๋ณต์žก, ์Šค์ผ€์ค„๋ง overhead๊ฐ€ ํผ
    • Starvation ๋ฌธ์ œ ๋“ฑ
  • ๋ณ€ํ˜•
    • ๊ฐ ์ค€๋น„ ํ๋งˆ๋‹ค ์‹œ๊ฐ„ ํ• ๋‹น๋Ÿ‰์„ ๋‹ค๋ฅด๊ฒŒ ๋ฐฐ์ •
      • ํ”„๋กœ์„ธ์Šค์˜ ํŠน์„ฑ์— ๋งž๋Š” ํ˜•ํƒœ๋กœ ์‹œ์Šคํ…œ ์šด์˜ ๊ฐ€๋Šฅ
    • ์ž…์ถœ๋ ฅ ์œ„์ฃผ ํ”„๋กœ์„ธ์Šค(I/O bounded process)๋“ค์„ ์ƒ์œ„ ๋‹จ๊ณ„์˜ ํ๋กœ ์ด๋™, ์šฐ์„  ์ˆœ์œ„ ๋†’์ž„
      • ํ”„๋กœ์„ธ์Šค๊ฐ€ block๋  ๋•Œ ์ƒ์œ„์˜ ์ค€๋น„ ํ๋กœ ์ง„์ž…ํ•˜๊ฒŒ ํ•จ
      • ์‹œ์Šคํ…œ ์ „์ฒด์˜ ํ‰๊ท  ์‘๋‹ต ์‹œ๊ฐ„ ์ค„์ž„, ์ž…์ถœ๋ ฅ ์ž‘์—… ๋ถ„์‚ฐ ์‹œํ‚ด
    • ๋Œ€๊ธฐ ์‹œ๊ฐ„์ด ์ง€์ •๋œ ์‹œ๊ฐ„์„ ์ดˆ๊ณผํ•œ ํ”„๋กœ์„ธ์Šค๋“ค์„ ์ƒ์œ„ ํ๋กœ ์ด๋™
      • ์—์ด์ง• (aging) ๊ธฐ๋ฒ•
  • Parameters for MFQ scheduling
    • Queue์˜ ์ˆ˜
    • Queue๋ณ„ ์Šค์ผ€์ค„๋ง ์•Œ๊ณ ๋ฆฌ์ฆ˜
    • ์šฐ์„  ์ˆœ์œ„ ์กฐ์ • ๊ธฐ์ค€
    • ์ตœ์ดˆ Queue ๋ฐฐ์ • ๋ฐฉ๋ฒ•

<์ฐธ๊ณ >

profile
https://rimi0108.github.io/

0๊ฐœ์˜ ๋Œ“๊ธ€