728x90
๋ฐ˜์‘ํ˜•

๐Ÿ–ฅ๏ธ  CPU Scheduling

์‹œ์Šคํ…œ์˜ CPU ์‚ฌ์šฉ ํšจ์œจ์„ ๊ทน๋Œ€ํ™”ํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์ค‘ ํ”„๋กœ๊ทธ๋ž˜๋ฐ๊ณผ ๋ฉ€ํ‹ฐํƒœ์Šคํ‚น ๊ธฐ์ˆ ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ

Resources (CPUํฌํ•จ)๋Š” process๋“ค ์‚ฌ์ด์—์„œ ๊ณต์œ ๋œ๋‹ค.

 

๐Ÿ–ฅ๏ธ CPU-IO Burst Cycle

ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹คํ–‰๋˜๋Š” ๋™์•ˆ CPU ์‚ฌ์šฉ(bursts)๊ณผ ์ž…์ถœ๋ ฅ(I/O) ๋Œ€๊ธฐ ์‹œ๊ฐ„ ์‚ฌ์ด๋ฅผ ๋ฒˆ๊ฐˆ์•„ ๊ฐ€๋ฉฐ ๋ฐ˜๋ณตํ•˜๋Š” ํ˜„์ƒ

 

Types of processes

  • I/O bound process
    • ์ž…๋ ฅ(input)๊ณผ ์ถœ๋ ฅ(output) ์ž‘์—…์— ๋” ๋งŽ์€ ์‹œ๊ฐ„์„ ์†Œ๋น„ํ•˜๋Š” ํ”„๋กœ์„ธ์Šค
  • CPU-bound process
    • ๊ณ„์‚ฐ์ด๋‚˜ ์ฒ˜๋ฆฌ ๊ณผ์ •์—์„œ ๋Œ€๋ถ€๋ถ„์˜ ์‹œ๊ฐ„์„ ์†Œ๋น„ํ•˜๋Š” ํ”„๋กœ์„ธ์Šค

 

๐Ÿ–ฅ๏ธ CPU Scheduler

CPU Scheduler๋Š” ready queue์—์„œ process๋ฅผ ์„ ํƒํ•˜๊ณ , CPU core๋ฅผ ํ• ๋‹นํ•œ๋‹ค.

 

When Scheduling Occurs?

  1. running์—์„œ waiting state์œผ๋กœ switch ๋  ๋•Œ (Nonpreemtive)
  2. running์—์„œ ready state์œผ๋กœ switch ๋  ๋•Œ (Preemtive)
  3. wating์—์„œ ready๋กœ switch ๋  ๋•Œ (Preemtive)
  4. ์ข…๋ฃŒ๋  ๋•Œ (Nonpreemtive)

 

Non-preemptive vs Preemptive

- Non-preemptive scheduling

  • ์•„๋ฌด๋„ interruptํ•  ์ˆ˜ ์—†๋‹ค.
  • running → waiting / terminate ๋  ๋•Œ๋งˆ๋‹ค ๋ฐœ์ƒํ•œ๋‹ค.
  • Running process๋Š” interrupted ๊ฐ€ ์•„๋‹ˆ๋‹ค.

- Preemptive scheduling

  • 1,2,3,4์—์„œ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋‹ค.
  • processing์ด ์‹คํ–‰ ์ค‘์ผ ๋•Œ scheduling์ด ๋ฐœ์ƒํ•œ๋‹ค.
    • interrupt, process with higher priority
  • HW์˜ ์ง€์›๊ณผ shared data handling์ด ํ•„์š”ํ•˜๋‹ค.
  • ์„ ์ ํ˜• ์Šค์ผ€์ค„๋ง์ด ์—ฌ๋Ÿฌ ํ”„๋กœ์„ธ์Šค ๊ฐ„์— ๋ฐ์ดํ„ฐ๋ฅผ ๊ณต์œ ํ•  ๋•Œ ๊ฒฝ์Ÿ ์ƒํƒœ(๋ ˆ์ด์Šค ์ปจ๋””์…˜)๋ฅผ ๋ฐœ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.

 

๐Ÿ–ฅ๏ธ Dispatcher

CPU๋ฅผ ํ˜„์žฌ ์‹คํ–‰ ์ค‘์ธ ํ”„๋กœ์„ธ์Šค์—์„œ ๋‹ค์Œ์— ์‹คํ–‰ํ•  ํ”„๋กœ์„ธ์Šค๋กœ ๋„˜๊ฒจ์ฃผ๋Š” ์šด์˜ ์ฒด์ œ์˜ ๋ชจ๋“ˆ์ด๋‹ค.
  • Switching Context
    • CPU๊ฐ€ ํ˜„์žฌ ์‹คํ–‰ ์ค‘์ธ ํ”„๋กœ์„ธ์Šค(P0)์˜ ์ƒํƒœ(์˜ˆ: ๋ ˆ์ง€์Šคํ„ฐ ๊ฐ’, ํ”„๋กœ๊ทธ๋žจ ์นด์šดํ„ฐ ๋“ฑ)๋ฅผ ์ €์žฅํ•˜๊ณ , ๋‹ค์Œ ํ”„๋กœ์„ธ์Šค(P1)์˜ ์ด์ „ ์ƒํƒœ๋ฅผ ๋ณต์›ํ•ฉ๋‹ˆ๋‹ค.
  • ์œ ์ € ๋ชจ๋“œ๋กœ ์ „ํ™˜(Switching to User Mode)
    • ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‚ฌ์šฉ์ž ๋ชจ๋“œ์—์„œ ์‹คํ–‰๋  ์ˆ˜ ์žˆ๋„๋ก CPU์˜ ๋ชจ๋“œ๋ฅผ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.
  • ์ ์ ˆํ•œ ์œ„์น˜๋กœ ์ ํ”„(Jumping to the Proper Location)
    • ํ”„๋กœ๊ทธ๋žจ์ด ์ค‘๋‹จ๋œ ๋ถ€๋ถ„๋ถ€ํ„ฐ ๊ณ„์† ์‹คํ–‰๋  ์ˆ˜ ์žˆ๋„๋ก ํ”„๋กœ๊ทธ๋žจ ์นด์šดํ„ฐ๋ฅผ ํ•ด๋‹น ์œ„์น˜๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

Dispatch Latency (์ง€์—ฐ)

ํ•œ ํ”„๋กœ์„ธ์Šค(P0)๋ฅผ ์ค‘๋‹จํ•˜๊ณ  ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค(P1)๊ฐ€ ์‹คํ–‰์„ ์‹œ์ž‘ํ•˜๋Š” ๋ฐ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„์„ ์˜๋ฏธํ•œ๋‹ค.

 

๐Ÿ–ฅ๏ธ Scheduling Criteria

  • CPU Utilization(CPU ์ด์šฉ๋ฅ ) : CPU๊ฐ€ ์–ผ๋งˆ๋‚˜ ๋ถ€์ง€๋Ÿฐํžˆ ์ผํ•˜๋Š”๊ฐ€. / ๋†’์„์ˆ˜๋ก ์ข‹์€๊ฑฐ์ž„ (๋‹จ์œ„ : %)
  • Throughput(์ฒ˜๋ฆฌ์œจ) : ์‹œ๊ฐ„๋‹น ๋ช‡๊ฐœ์˜ ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•˜๋Š”๊ฐ€. / ๋†’์„์ˆ˜๋ก ์ข‹์€๊ฑฐ์ž„ (๋‹จ์œ„ : job/sec)
  • Turnaround time(๋ฐ˜ํ™˜์‹œ๊ฐ„) : ์ž‘์—…์ด ๋ฉ”์ธ๋ฉ”๋ชจ๋ฆฌ๋กœ ๋๋‚ด๊ณ  ๋‚˜์˜ฌ๋•Œ๊นŒ์ง€ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„. / ์งง์„์ˆ˜๋ก ์ข‹์€๊ฑฐ์ž„ (๋‹จ์œ„ : sec)
  • Waiting time(๋Œ€๊ธฐ์‹œ๊ฐ„) : CPU์—์„œ ์„œ๋น„์Šค๋ฅผ ๋ฐ›๊ธฐ ์œ„ํ•ด ReadyQueue์—์„œ ๊ธฐ๋‹ค๋ฆฌ๋Š” ์‹œ๊ฐ„. / ์งง์„์ˆ˜๋ก ์ข‹์ง€ (๋‹จ์œ„ : sec)
  • Response time(์‘๋‹ต์‹œ๊ฐ„) : ์ปดํ“จํ„ฐ์™€ ๋Œ€ํ™”ํ•˜๋Š” ์‹œ์Šคํ…œ์—์„œ ์ค‘์š”ํ•จ. (์š”์ƒˆ๋Š” ๋‹ค ๋งž๊ธดํ•จ) / ์งง์„์ˆ˜๋ก ์ข‹์Œ (๋‹จ์œ„ : sec)
728x90
๋ฐ˜์‘ํ˜•

+ Recent posts