CS ๊ณต๋ถ€

[์šด์˜์ฒด์ œ] CPU ์Šค์ผ€์ค„๋ง

์€์ง„ 2021. 8. 7. 14:39

๋ฉ€ํ‹ฐํ”„๋กœ๊ทธ๋ž˜๋ฐ์€

์—ฌ๋Ÿฌ ๊ฐœ์˜ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋™์‹œ์— ๋ฉ”๋ชจ๋ฆฌ์— ๋กœ๋“œ๋˜๋Š”๋ฐ

๊ฐ ํ”„๋กœ์„ธ์Šค๊ฐ€ cpu๋ฅผ ์„ ์ ํ•ด์„œ concurrentํ•˜๊ฒŒ ์‹คํ–‰๋˜๋Š” ๊ฒƒ์„

๋ฉ€ํ‹ฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด๋ผ๊ณ  ํ•จ (๋ฉ€ํ‹ฐ ํ…Œ์Šคํ‚น)

 

concurrent์˜ ๋ชฉ์ 

์ „์ œ์กฐ๊ฑด : cpu๊ฐ€ ๋งค์šฐ ๋นจ๋ผ์„œ ๋†€๊ณ ์žˆ์„ ๋•Œ ์‹œ๋ถ„ํ• ํ•˜์—ฌ cpu์ž์›์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ

cpu utilization์„ ๋Š˜๋ฆฌ๊ธฐ ์œ„ํ•ด ์Šค์ผ€์ค„๋ง์ด ํ•„์š”ํ•จ

 

 

cpu ์Šค์ผ€์ค„๋Ÿฌ

ready์ƒํƒœ์˜ ํ”„๋กœ์„ธ์Šค๋“ค ์ค‘์— cpu๋ฅผ ํ• ๋‹นํ•ด์ค„ ์ˆ˜ ์žˆ๋Š” ํ”„๋กœ์„ธ์Šค๋ฅผ ์„ ํƒ

ํ˜„ cpu running ์ค‘์ธ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์žˆ๊ณ  ready์ธ ํ”„๋กœ์„ธ์Šค ์ค‘ ์–ด๋Š ํ”„๋กœ์„ธ์Šค๋ฅผ ์„ ํƒํ•  ๊ฒƒ์ธ๊ฐ€?

 

 

preemptive(์„ ์ ํ˜•) vs non-preemptive (๋น„์„ ์ ํ˜•)

์„ ์ ํ˜• : ๊ฐ•์ œ๋กœ ์ซ“์•„๋‚ผ ์ˆ˜ ์žˆ๋‹ค. <-> ์ž๋ฐœ์ ์œผ๋กœ ๋‚˜๊ฐ€๊ฒŒ

์Šค์ผ€์ค„๋Ÿฌ๊ฐ€ ํ• ๋‹น ์ค‘์ธ ํ”„๋กœ์„ธ์„œ๋ฅผ ์ซ“์•„๋‚ผ ์ˆ˜ ์žˆ๋‹ค.

๋น„์„ ์ ํ˜• : cpu๋ฅผ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์„ ์ ํ•˜๊ณ  ๋‚˜๋ฉด, releaseํ•˜๊ธฐ ์ „๊นŒ์ง€๋Š” ์ž๋ฐœ์  ๋‚˜์˜ค๊ธฐ ์ „ ๊นŒ์ง€๋Š” ํ”„๋กœ์„ธ์Šค๊ฐ€ ์“ฐ๋„๋ก ๋‚ด๋ฒ„๋Ÿฌ๋‘ 

 

 

1. running -> waiting :  cpu์„ ์  ์ค‘์ด๋‹ค๊ฐ€ I/O๋กœ

2. running -> ready 

3. waiting -> ready : ํŒŒ์ผ ์ž…์ถœ๋ ฅ ๋๋‚จ, cpu ์ ์œ ํ•˜๋Ÿฌ ready๋กœ ๊ฐ

4. ํ”„๋กœ์„ธ์Šค terminate

 

1, 4 -> ์ž๋ฐœ์ ์œผ๋กœ ์ด๋™ (๋น„์„ ์ ํ˜•)

2, 3 -> ready๋กœ ๊ฐ”์œผ๋‚˜ cpu๋ฅผ ์„ ์ ํ•  ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋†’์œผ๋ฉด cpu์— ํ˜„ ํ• ๋‹น์ค‘์ธ ํ”„๋กœ์„ธ์Šค๋ฅผ ์ซ“์•„๋‚ผ ์ˆ˜ ์žˆ์ฃ !

(์„ ์ ํ˜•(V) ๋˜๋Š” ๋น„์„ ์ ํ˜•(๋น„ํšจ์œจ์ ))

 

 

 

dispatcher

context switch๋ฅผ ํ•ด์ฃผ๋Š” ๋ชจ๋“ˆ

ํ”„๋กœ์„ธ์Šค์—๊ฒŒ cpu๋ฅผ ๋„˜๊ฒจ์คŒ

(cpu running -> waiting or ready ์ซ“์•„๋ƒ„ -> ready์˜ ํ”„๋กœ์„ธ์Šค๋ฅผ ํ• ๋‹น)

 

ํ•  ์ผ:

cpu๋ฅผ ํ•˜๋‚˜์˜ ํ”„๋กœ์„ธ์Šค์—์„œ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค๋กœ ํ• ๋‹นํ•ด์ฃผ๊ณ 

์ƒˆ๋กœ์šด ํ”„๋กœ์„ธ์Šค์˜ ์ ๋‹นํ•œ ์œ„์น˜๋กœ resumeํ•ด์คŒ

 

์Šค์ผ€์ค„๋Ÿฌ : ํ”„๋กœ์„ธ์Šค๋ฅผ ์„ ํƒ

dispatcher : ์‹ค์ œ context switching๋ฅผ ์ˆ˜ํ–‰

 

 

dispatcher๊ฐ€ ๋ชน์‹œ ๋นจ๋ผ์•ผ ํ•จ!

dispatcher latency๋Š” ๊ฐ€๊ธ‰์  ์งง์•„์•ผํ•œ๋‹ค.

 

 

 

dispatcher latency๋ž€?

ํ”„๋กœ์„ธ์Šค๋ฅผ ๋ฉˆ์ถ”๊ณ  ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค๋ฅผ runningํ•˜๋Š” ์‹œ๊ฐ„

 

 

์Šค์ผ€์ค„๋ง ๋ชฉํ‘œ 

cpu utilizaion : cpu๋ฅผ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉํ•˜๊ธฐ busy

throughput : ๋‹จ์œ„์‹œ๊ฐ„ ๋‚ด ์™„๋ฃŒ๋œ ํ”„๋กœ์„ธ์Šค์˜ ํšŸ์ˆ˜ ์ฆ๊ฐ€

turnaround time : ํ”„๋กœ์„ธ์Šค ๋„์ฐฉ ~ ์ข…๋ฃŒ๊นŒ์ง€ ์‹œ๊ฐ„ ์ตœ์†Œํ™”

waiting time !์ค‘์š”! : ํ”„๋กœ์„ธ์Šค๊ฐ€ ready queue์—์„œ ๋Œ€๊ธฐํ•˜๋Š” ์‹œ๊ฐ„์„ ์ตœ์†Œํ™”

response time : ์‘๋‹ต์‹œ๊ฐ„ ์ตœ์†Œํ™”

 

 

 

<์Šค์ผ€์ค„๋ง ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์ข…๋ฅ˜>

1. FCFS : first come first served ๋จผ์ €์˜จ ์ˆœ์„œ๋Œ€๋กœ ์ฒ˜๋ฆฌ, ๊ณตํ‰

๋ฌธ์ œ๋งŽ์Œ, ์ดˆ์ฐฝ๊ธฐ ์šด์˜์ฒด์ œ์„œ ์‚ฌ์šฉ

2. SJF : shortest job first , SRTF : shortest remaining time first (๋‚จ์€ ์‹œ๊ฐ„์ด ๊ฐ€์žฅ ์ ์€ ๊ฒƒ)

์•„๋ž˜๋ถ€ํ„ฐ ์‹œ๋ถ„ํ•  ๊ด€๋ จ time-sharing

3. RR : round-robin ์ •ํ•ด์ง„ ์‹œ๊ฐ„๋งŒํผ๋งŒ

t1, t2, t3, ... ready queue์— ์žˆ๋‹ค๊ฐ€ ์ •ํ•ด์ง„ ์‹œ๊ฐ„๋งŒํผ๋งŒ ์‚ฌ์šฉ

4. priority-based : RR์„ ์“ฐ๋Š”๋ฐ, ์šฐ์„ ์ˆœ์œ„๋ฅผ ๋ถ€์–ด

5. MLQ : multi-level queue : ์šฐ์„ ์ˆœ์œ„์— ๋”ฐ๋ผ ready queue๋ฅผ ๋”ฐ๋กœ

6. MLFQ : multi level feedback queue : ready queue๋ฅผ ๋”ฐ๋กœ + ์šฐ์„ ์ˆœ์œ„ ์ˆ˜์ •, ํ˜„๋Œ€์  ์Šค์ผ€์ค„๋Ÿฌ

 

 

 

FCFS

๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ ์•Œ๊ณ ๋ฆฌ์ฆ˜

CPU๋ฅผ ๋จผ์ € ์š”์ฒญํ•œ ํ”„๋กœ์„ธ์Šค์—๊ฒŒ ๋จผ์ € ํ• ๋‹น

queue์— ๋„ฃ์–ด ๋Œ€๊ธฐ์‹œํ‚ค๊ณ , ๋‹ค ์‹คํ–‰ํ•˜๋ฉด ๋‚˜๊ฐ€๊ณ  ...

์ˆœ์„œ๋Œ€๋กœ ์ฒ˜๋ฆฌ

 

 

FCFS

p1 - p2 - p3

burst time

p1 24, 

p2 3

p3 3

 

waiting time

์•ž์˜ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋๋‚  ๋•Œ๊นŒ์ง€ ๊ณ„์† ๋Œ€๊ธฐ

p1 = 0

p2 = 24

p3 = 27

total 51

average 51/3 = 17

average waiting time์„ ์ค„์ผ ๋ฐฉ๋ฒ•์€?

 

 

p2 - p3 - p1

p1 = 6, pw = 0, p3 = 3

total = 9

average = 3

 

 

turnaround time : ๋„์ฐฉ ~ ์ข…๋ฃŒ๊นŒ์ง€

 

 

p2 - p3 - p1

p1 = 30, p2 = 3, p3 = 6

total = 39

average = 13 

 

 

note

average waiting time์ด cpu-burst time์ด ์–ผ๋งˆ๋ƒ์— ๋”ฐ๋ผ ๋งค์šฐ ๋‹ฌ๋ผ์ง

FCFS๋Š” ๋น„์„ ์ ํ˜•. ๋‹ค ๋๋‚ ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆผ

 

cpu bound 1๊ฐœ์™€ I/O bound ์—ฌ๋Ÿฌ ๊ฐœ๊ฐ€ ์žˆ์„ ๋•Œ 

(cpu ๋งŽ์ด ์“ฐ๋Š” ํ”„๋กœ์„ธ์Šค์™€ , cpu๋Š” ์ ๊ฒŒ ์“ฐ์ง€๋งŒ I/O๋ฅผ ๋งŽ์ด ์“ฐ๋Š” ํ”„๋กœ์„ธ์Šค)

 

convoy effect ํ˜ธ์†ก ํšจ๊ณผ, ๋˜ฅ์ฐจ ํšจ๊ณผ

(์Šคํฌ์ธ ์นด๋“ค์ด ๋˜ฅ์ฐจ ๋•Œ๋ฌธ์— ๋ง‰ํžŒ๋‹ค)

cpu ๋‹ค ์“ธ๋•Œ๊นŒ์ง€ ํ•˜์—ผ์—†์ด ๊ธฐ๋‹ค๋ ค์•ผํ•จ

cpu ์ž ๊น๋งŒ ์“ฐ๋ฉด ๋˜๋Š”๋ฐ

 

๋”ฐ๋ผ์„œ FCFS๋Š” ๋น„ํšจ์œจ์ ์ด๋‹ค

 

 

 

 

SJF

sortest next cpu burst first ์Šค์ผ€์ค„๋ง

ํ”„๋กœ์„ธ์Šค์˜ next CPU burst time์„ ๊ณ„์‚ฐํ•˜์—ฌ ๊ฐ€์žฅ ์ž‘์€ ๊ฒƒ์„ ํ• ๋‹น

 

 

 

 

 

SJF : provabily optimal ์ตœ์ ์ด๋ผ๋Š” ๊ฒƒ์ด ์ฆ๋ช…๊ฐ€๋Šฅํ•˜๋‹ค

์ด๋ก ์ ์œผ๋กœ ์ตœ์ 

average waiting time์ด ์ตœ์†Œ๋‹ค.

short ํ”„๋กœ์„ธ์Šค์˜ waiting time์˜ ๊ฐ์†Œ

 

์‹ค์ œ ์‚ฌ์šฉํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ์•„๋‹ˆ๋‹ค.

๊ตฌํ˜„์ด ๋ถˆ๊ฐ€ํ•˜๋‹ค

next CPU burst๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์‚ผ๋Š”๋ฐ ์•Œ์ˆ˜์žˆ๋Š” ๋ฐฉ๋ฒ•์ด ์—†๋‹ค.

cpu ์–ผ๋งˆ๋‚˜ ์“ฐ๋Š”์ง€ ์˜ˆ์ธกํ•  ์ˆ˜ ์—†๋‹ค.

 

SJF๋ฅผ ์—„๊ฒฉํ•˜๊ฒŒ ๊ตฌํ•  ์ˆ˜ ์—†๊ณ , ์˜ˆ์ธกํ•˜์—ฌ ๊ทผ์‚ฌ์ ์œผ๋กœ ๊ตฌํ•˜์ž

predicted CPU burst๊ฐ€ ๊ฐ€์žฅ ์งง์€ ํ”„๋กœ์„ธ์Šค๋ฅผ ์„ ํƒํ•˜์ž.

๊ณผ๊ฑฐ๋ฅผ ๋ณด์ž. previous cpu burst๋ฅผ ๋ณด์ž. 

 

๊ณผ๊ฑฐ์— ์ธก์ •๋œ ๊ฐ’์„ ๋ณด๊ณ , ์ง€์ˆ˜์  ํ‰๊ท ์„ ๋‚ด์ž

์•ŒํŒŒ๊ฐ€ 0 --> ์™„์ „ํžˆ ๊ณผ๊ฑฐ ๊ธฐ๋ก๋งŒ

์•ŒํŒŒ๊ฐ€ 1 --> ์™„์ „ํžˆ ์ตœ๊ทผ ๊ธฐ๋ก๋งŒ

 

 

 

SJF๋Š” preemptive or non-premptive

์ƒˆ๋กœ์šด ํ”„๋กœ์„ธ์Šค๊ฐ€ ready queue์— ๋„์ฐฉํ–ˆ์„ ๋•Œ

p1์˜ cpu burst time์ด ๋” ์งง์•„๋„ cpu ์„ ์  ์ค‘์ธ p0๊ฐ€ ๋๋‚  ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ ค์ฃผ๋Š” ๊ฒฝ์šฐ non-preemptive SJF

p1์˜ cpu burst time์ด ๋” ์งง์•„์„œ p0๋ฅผ ready queue์— ๋„ฃ๊ณ  p1๊ฐ€ cpu ์„ ์ ํ•  ๊ฒฝ์šฐ preemptive SJF

 

 

 

SRTF : shortest remaining time first : preemptive SJF

์ƒˆ ํ”„๋กœ์„ธ์Šค์˜ cpu burst๊ฐ€, ์‹คํ–‰ ์ค‘์ธ ํ”„๋กœ์„ธ์Šค์˜ remaining time๋ณด๋‹ค ๋” ์ž‘์œผ๋ฉด ์ƒˆ ํ”„๋กœ์„ธ์Šค๋ฅผ ์„ ์ ํ•œ๋‹ค.

 

 

 

 

 

 

 

 

์„ ์ ํ˜•์ธ SRTF (ํšจ์œจ์ ) < ๋น„์„ ์ ํ˜•์ธ SJF

 

 

 

RR

time sharing

round robin :  preemptive FCFS ์‹œ๊ฐ„๋‹จ์œ„๋ฅผ ์คŒ (time quantum, ๋ณดํ†ต 10 millisecond)

๋‹จ์œ„์‹œ๊ฐ„ ๋‚ด์— ํ”„๋กœ์„ธ์Šค๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ๋‹จ์œ„์‹œ๊ฐ„์ด ๋๋‚˜๋ฉด ๋‚ด๋ณด๋ƒ„

circular queue

cpu burst๊ฐ€ ํ•œ ์‹œ๊ฐ„๋‹จ์œ„๋ณด๋‹ค ์งง์„ ๋•Œ

- ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ž๋ฐœ์ ์œผ๋กœ cpu release

 

cpu burst๊ฐ€ ํ•œ ์‹œ๊ฐ„๋‹จ์œ„๋ณด๋‹ค ๊ธธ ๋•Œ

 - ํƒ€์ด๋จธ๊ฐ€ interrupt

 - context swtich ์‹คํ–‰

 - ํ”„๋กœ์„ธ์Šค๊ฐ€ ready queue์˜ ๋tail์— ๋“ค์–ด๊ฐ

 

 

 

RR์—์„œ average waiting time์ด ์ข€ ๋” ๊ธธ ์ˆ˜ ์žˆ๋‹ค.

ํ•˜์ง€๋งŒ SJF์™€ ์„ž์–ด์“ฐ๋Š” ์ˆœ๊ฐ„, ์œ ์šฉ

RR์€ ๋ฐ˜๋“œ์‹œ ์ ์šฉ๋จ

 

RR์€ preemptive

cpu burst๊ฐ€ ํ•œ ์‹œ๊ฐ„๋‹จ์œ„๋ณด๋‹ค ์ดˆ๊ณผํ•˜๋ฉด, ๊ฐ•์ œ๋กœ ์ซ“๊ฒจ๋‚จ, ๋‹ค์‹œ ready queue๋กœ ๋Œ์•„๊ฐ

 

time quantum์— ๋”ฐ๋ผ์„œ ์„ฑ๋Šฅ ๋‹ฌ๋ผ์ง

 

 

context switch๋งˆ๋‹ค dispatch latency ๋ฐœ์ƒ!!

- dispatch latency๋ฅผ ์ตœ์†Œํ™”ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์œผ๋‚˜

- ๊ทธ๋ ‡๋‹ค๊ณ  quantum์ด ๋ฌดํ•œ๋Œ€๊ฐ€ ๋˜๋ฉด FCFS๊ฐ€ ๋จ

- quaumtum์ด ๋„ˆ๋ฌด ์ž‘์œผ๋ฉด context switch๊ฐ€ ๋„ˆ๋ฌด ์ž์ฃผ ์ผ์–ด๋‚˜ dispatch latency๊ฐ€ ๊ธธ์–ด์ง

 

 

 

 

- time quantum์„ ๋„ˆ๋ฌด ๋งŽ์ด ์ค˜๋„, ๋„ˆ๋ฌด ์ ๊ฒŒ ์ค˜๋„ turnaround time์ด ์ค„์–ด๋“ฆ

- ์ ์ ˆํžˆ turnaround time์ด ๋†’๊ฒŒ๋” quantum์„ ์ง€์ •ํ•ด์ค˜์•ผ

 

 

Priority-base ์šฐ์„ ์ˆœ์œ„ ์Šค์ผ€์ค„๋ง

์šฐ์„ ์ˆœ์œ„๋ฅผ ์–ด๋–ป๊ฒŒ ๋ถ€์—ฌํ•  ๊ฒƒ์ธ๊ฐ€?

์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋†’์€ ํ”„๋กœ์„ธ์Šค์—๊ฒŒ cpu ํ• ๋‹น

์šฐ์„ ์ˆœ์œ„๊ฐ€ ๊ฐ™์€ ๊ฒฝ์šฐ FCFS

 

SJF - predicted next CPU burst๊ฐ€ ์งง์„ ๊ฒฝ์šฐ ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋†’๋‹ค

 

 

 

preemptive : SRTF

non-preemptive : SJF

 

priority scheduling์—์„œ ํ•ญ์ƒ ๋”ฐ๋ฅด๋Š” ๋ฌธ์ œ : 

starvation ๊ธฐ์•„! indefinite blocking ๋ฌดํ•œ์ • ๋Œ€๊ธฐ

์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋‚ฎ์€ ํ”„๋กœ์„ธ์Šค๋Š” ๋ฌดํ•œ์ • ๊ธฐ๋‹ค๋ ค์•ผํ• ์ง€๋„ ๋ชจ๋ฅธ๋‹ค.

 

ํ•ด๊ฒฐ๋ฐฉ๋ฒ• : aging

์˜ค๋ž˜ ๊ธฐ๋‹ค๋ฆฐ ์‹œ์Šคํ…œ์—๊ฒŒ๋Š” ์šฐ์„ ์ˆœ์œ„ ๋†’์—ฌ์ฃผ๊ธฐ

 

 

RR + Priority scheduling

- ์šฐ์„ ์ˆœ์œ„๋ฅผ ์šฐ์„ ์ ์œผ๋กœ ๋ณด๋˜

- ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๊ฐ™์„ ๊ฒฝ์šฐ, round-robin ์Šค์ผ€์ค„๋ง

 

 

 

Multi-level queue MLQ ์Šค์ผ€์ค„๋ง

์šฐ์„ ์ˆœ์œ„์— ๋”ฐ๋ผ ready queue๋ฅผ ๋”ฐ๋กœ

 

 

 

 

 

 

 

Multi level feedback queue MLFQ ์Šค์ผ€์ค„๋ง

 

- ์šฐ์„  ์—ฌ๋Ÿฌ ๊ฐœ์˜ ํ๊ฐ€ ์กด์žฌ

- ํ๋“ค์€ ๊ฐ๊ฐ ๋‹ค๋ฅธ ๋ ˆ๋ฒจ์˜ ์šฐ์„ ์ˆœ์œ„๋ฅผ ๊ฐ€์ง€๋ฏ€๋กœ multi level queue

- ๊ณผ๊ฑฐ์˜ ์ˆ˜ํ–‰ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ  ์šฐ์„ ์ˆœ์œ„๋ฅผ ๋ณ€๊ฒฝํ•ด์ฃผ๋Š” ์‹์˜ ๋ฐฉ๋ฒ•์ด๋ฏ€๋กœ feedback์ด๋ผ๋Š” ๋‹จ์–ด๋„ ์ถ”๊ฐ€๋์Šต๋‹ˆ๋‹ค.

 

  • ๊ทœ์น™ 1 : ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋†’์€ ํ”„๋กœ์„ธ์Šค๋“ค์„ ๋จผ์ € ์ˆ˜ํ–‰ํ•œ๋‹ค.
  • ๊ทœ์น™ 2 : ์ž‘์—…๋“ค์ด ๊ฐ™์€ ์šฐ์„ ์ˆœ์œ„๋ฅผ ๊ฐ–๋Š”๋‹ค๋ฉด RR๋กœ ์ˆ˜ํ–‰ํ•œ๋‹ค.
  • ๊ทœ์น™ 3 : ์ƒˆ๋กœ์šด ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‹œ์Šคํ…œ์— ๋“ค์–ด๊ฐ€๋ฉด ๊ฐ€์žฅ ๋†’์€ ์šฐ์„ ์ˆœ์œ„๋ฅผ ๋ถ€์—ฌํ•œ๋‹ค.
  • ๊ทœ์น™ 4 : ์ž‘์—…์€ ๋ชจ๋“  ์šฐ์„ ์ˆœ์œ„์—์„œ ์ฃผ์–ด์ง„ time quauntum๋ฅผ ๋ชจ๋‘ ์‚ฌ์šฉํ•˜๋ฉด ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๊ฐ์†Œํ•œ๋‹ค.

๊ทœ์น™ 5 : ์ผ์ • ์‹œ๊ฐ„ ํ›„ ์‹œ์Šคํ…œ์˜ ๋ชจ๋“  ์ž‘์—…์„ ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๊ฐ€์žฅ ๋†’์€ ํ๋กœ ์ด๋™ํ•œ๋‹ค.

 

 

modern OS

์‹ค์ œ๋กœ๋Š” Thread ์Šค์ผ€์ค„๋ง์„ ํ•จ, not process

์ปดํ“จํ„ฐ์—์„œ task๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์œ„๋Š” Thread

๊ฒฐ๋ก  : OS ์ปค๋„์€, ์ปค๋„ Thread๋ฅผ ๋Œ€์ƒ์œผ๋กœ CPU ์Šค์ผ€์ค„๋ง์„ ํ•œ๋‹ค.

 

 

SQMS

ํ•˜๋‚˜์˜ ํ์— ์ž‘์—…๋“ค์„ ๋„ฃ์–ด์„œ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ SQMS(Single Queue Multprocessor Scheduling)

 

- ๋‹จ์ˆœํ•˜๋‹ค๋Š” ์žฅ์ 

- ์Šค์ผ€์ค„๋Ÿฌ๊ฐ€ ์—ฌ๋Ÿฌ CPU์—์„œ ์ž˜ ์ž‘๋™ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด Lock์„ ์‚ฌ์šฉ

- Lock์„ ์‚ฌ์šฉํ•˜๋ฉด ์„ฑ๋Šฅ์„ ํฌ๊ฒŒ ์ €ํ•˜์‹œํ‚ฌ ์ˆ˜ ์žˆ์Œ

- ์‹ค์ œ ํ”„๋กœ๊ทธ๋žจ ์ˆ˜ํ–‰ ์‹œ๊ฐ„๋ณด๋‹ค Lock์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์ž‘์—…์— ๋” ๋งŽ์€ ์‹œ๊ฐ„์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ

 

Lock : ์—ฌ๋Ÿฌ CPU๊ฐ€ ๋™์‹œ์— ๊ณต์œ  ๋ฐ์ดํ„ฐ๊ฐ€ ์ ‘๊ทผํ•  ๋•Œ, ๋ฐ์ดํ„ฐ์˜ ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•˜๊ธฐ ์œ„ํ•จ

 

 

 

MQMS

SQMS์—์„œ์˜ ๋ฌธ์ œ์ ์„ ๋ณด์™„ํ•œ MQMS(Multi Queue Multiprocessor Scheduling)

 

- SQMS์™€์˜ ์ฐจ์ด์  : ํ๊ฐ€ ์—ฌ๋Ÿฌ ๊ฐœ

- ๊ฐ๊ฐ์˜ ํ๋Š” RR๊ณผ ๊ฐ™์€ ํŠน์ •ํ•œ ์Šค์ผ€์ค„๋ง ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉ

- ์ž‘์—…์ด ์‹œ์Šคํ…œ์— ๋“ค์–ด์˜ค๋ฉด ํ•˜๋‚˜์˜ ํ์—๋งŒ ๋ฐฐ์น˜๋˜๊ณ , CPU ๋…๋ฆฝ์ ์œผ๋กœ ์Šค์ผ€์ค„๋ง

 

 

 

 

์ถœ์ฒ˜ : https://www.inflearn.com/course/%EC%9A%B4%EC%98%81%EC%B2%B4%EC%A0%9C-%EA%B3%B5%EB%A3%A1%EC%B1%85-%EC%A0%84%EA%B3%B5%EA%B0%95%EC%9D%98/dashboard [์ธํ”„๋Ÿฐ]

์ถœ์ฒ˜: https://icksw.tistory.com/127 [PinguiOS]