๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’ป CS/์šด์˜์ฒด์ œ

[์šด์˜์ฒด์ œ] 12. Disk Management and Scheduling

by nitronium102 2023. 1. 29.

Disk Structure

1) Logical Block

- ๋””์Šคํฌ์˜ ์™ธ๋ถ€์—์„œ ๋ณด๋Š” ๋””์Šคํฌ์˜ ๋‹จ์œ„ ์ •๋ณด ์ €์žฅ ๊ณต๊ฐ„๋“ค

- ์ฃผ์†Œ๋ฅผ ๊ฐ€์ง„ 1์ฐจ์› ๋ฐฐ์—ด์ฒ˜๋Ÿผ ์ทจ๊ธ‰

- ์ •๋ณด๋ฅผ ์ „์†กํ•˜๋Š” ์ตœ์†Œ ๋‹จ์œ„

 

2) Sector

- Logical Block์ด ๋ฌผ๋ฆฌ์ ์ธ ๋””์Šคํฌ์— ๋งคํ•‘๋œ ์œ„์น˜

- Sector 0์€ ์ตœ์™ธ๊ณฝ ์‹ค๋ฆฐ๋”์˜ ์ฒซ ํŠธ๋ž™์— ์žˆ๋Š” ์ฒซ ๋ฒˆ์งธ ์„นํ„ฐ์ด๋‹ค (Booting๊ณผ ๊ด€๋ จ๋จ)

 

Disk Management

1) Physical formatting (Low-level formatting)

header, trailer์— metadata ์ €์žฅ

- ๋””์Šคํฌ๋ฅผ ์ปจํŠธ๋กค๋Ÿฌ๊ฐ€ ์ฝ๊ณ  ์“ธ ์ˆ˜ ์žˆ๋„๋ก ์„นํ„ฐ๋“ค๋กœ ๋‚˜๋ˆ„๋Š” ๊ณผ์ • (์š”์ฆ˜์€ ๋ฏธ๋ฆฌ formatting๋˜์–ด ๋‚˜์˜จ๋‹ค)

- ๊ฐ ์„นํ„ฐ๋Š” header + ์‹ค์ œ data(512B) + trailer๋กœ ๊ตฌ์„ฑ

- header๊ณผ trailer๋Š” secter number, ECC(Error-Correcting Code) ๋“ฑ์˜ ์ •๋ณด๊ฐ€ ์ €์žฅ๋˜๋ฉฐ controller๊ฐ€ ์ง์ ‘ ์ ‘๊ทผ ๋ฐ ์šด์˜

 

* ECC

๋ฐ์ดํ„ฐ๋ฅผ ์ž‘๊ฒŒ ์š”์•ฝํ•œ fingerprint๋ฅผ ํ•จ๊ป˜ ์ €์žฅํ•˜์—ฌ ๋ฐ์ดํ„ฐ ๊บผ๋‚ผ ๋•Œ ๋น„๊ต. ์ฃผ๋กœ ํ•ด์‹œ ํ•จ์ˆ˜ ์‚ฌ์šฉ

์ƒ๋‹นํ•œ ์–‘์˜ ์—๋Ÿฌ๋ฅผ ์žก์•„๋‚ผ ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๊ทœ๋ชจ์— ๋”ฐ๋ผ ๋ฐ์ดํ„ฐ์˜ ์ˆ˜์ •๊นŒ์ง€๋„ ๊ฐ€๋Šฅํ•˜๋‹ค

 

2) Partitioning

๋””์Šคํฌ๋ฅผ ํ•˜๋‚˜ ์ด์ƒ์˜ ์‹ค๋ฆฐ๋” ๊ทธ๋ฃน์œผ๋กœ ๋‚˜๋ˆ„๋Š” ๊ณผ์ •

- physical formatting ์ดํ›„์— ์„นํ„ฐ ์˜์—ญ์„ ๋ฌถ์–ด ํ•˜๋‚˜์˜ ๋…๋ฆฝ์ ์ธ ๋””์Šคํฌ๋กœ ๋งŒ๋“œ๋Š” ๊ณผ์ • ex) C, D ๋“œ๋ผ์ด๋ธŒ

- OS๋Š” ์ด๊ฒƒ์„ ๋…๋ฆฝ์  disk๋กœ ์ทจ๊ธ‰ํ•œ๋‹ค(logical disk)

 

3) Logical formatting

ํŒŒ์ผ ์‹œ์Šคํ…œ์„ ๋งŒ๋“œ๋Š” ๊ฒƒ

FAT, inode, free space ๋“ฑ์˜ ๊ตฌ์กฐ ํฌํ•จ

 

4) Booting

- ROM(๋น„ํœ˜๋ฐœ์„ฑ)์— ์žˆ๋Š” "small bootstrap loader"๊ฐ€ CPU์— ์˜ํ•ด instruction ํ˜•ํƒœ๋กœ ์‹คํ–‰

- sector 0 (boot block)์„ loadํ•˜์—ฌ ์‹คํ–‰

- sector 0์€ "full bootstrap loader program"

- OS๋ฅผ disk์—์„œ loadํ•˜์—ฌ ์‹คํ–‰

 

Disk Scheduling

1) Access time

- Seek time : ํ—ค๋“œ๋ฅผ ํ•ด๋‹น ์‹ค๋ฆฐ๋”๋กœ ์›€์ง์ด๋Š” ์‹œ๊ฐ„ (๊ฐ€์žฅ ์˜ค๋ž˜ ๊ฑธ๋ฆผ)

- Rotational Latency : ํ—ค๋“œ๊ฐ€ ์›ํ•˜๋Š” ์„นํ„ฐ์— ๋„๋‹ฌํ•˜๊ธฐ๊นŒ์ง€ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„ (seek time์˜ 1/10)

- Transfer time : ์‹ค์ œ ๋ฐ์ดํ„ฐ์˜ ์ „์†ก ์‹œ๊ฐ„

 

2) Disk bandwidth

๋‹จ์œ„ ์‹œ๊ฐ„ ๋‹น ์ „์†ก๋œ ๋ฐ”์ดํŠธ์˜ ์ˆ˜

 

3) Disk scheduling

- seek time์„ ์ตœ์†Œํ™”ํ•˜๋Š” ๊ฒƒ์ด ๋ชฉํ‘œ (ํ•œ ๋ฒˆ์˜ seek๋กœ ์ตœ๋Œ€ํ•œ ๋งŽ์€ ๋ฐ์ดํ„ฐ๋ฅผ transfer)

- seek time = seek distance

 

Disk Scheduling Algorithm

1) FCFS (First Come First Service)

- ๋“ค์–ด์˜จ ์ˆœ์„œ๋Œ€๋กœ ์ฒ˜๋ฆฌ. ๋น„ํšจ์œจ์ 

 

2) SSTF (Shortest Seek Time First)

- queue์— ๋“ค์–ด์˜จ ์š”์ฒญ ์ค‘ ํ˜„์žฌ head์— ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ์œ„์น˜์˜ ์š”์ฒญ์„ ๋จผ์ € ์ฒ˜๋ฆฌ -> ์ด๋™ ๊ฑฐ๋ฆฌ๊ฐ€ ์ค„์–ด๋“ ๋‹ค

- starvation ๋ฐœ์ƒ ๊ฐ€๋Šฅ (๋ฉ€๋ฆฌ ์žˆ๋Š” ๊ฒƒ)

3) SCAN (Elevator scheduling)

- ํ์— ์–ด๋–ค ์š”์ฒญ์ด ๋“ค์–ด์™”๋˜ ๋””์Šคํฌ ํ•œ ์ชฝ ๋์—์„œ ๋‹ค๋ฅธ ์ชฝ ๋์œผ๋กœ ์ด๋™ํ•˜๋ฉฐ ๊ฐ€๋Š” ๊ธธ๋ชฉ์— ์žˆ๋Š” ๋ชจ๋“  ์š”์ฒญ ์ฒ˜๋ฆฌ

- disk head์˜ ์ด๋™ ๊ฑฐ๋ฆฌ๋„ ์ค„์–ด๋“ค๊ณ  starvation๋„ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š”๋‹ค

- ์‹ค๋ฆฐ๋” ์œ„์น˜์— ๋”ฐ๋ผ ๋Œ€๊ธฐ ์‹œ๊ฐ„์ด ๋‹ค๋ฅด๋‹ค (๊ฐ€์šด๋ฐ ๋ถ€๋ถ„์€ ์–‘์ชฝ ๊ฐ€์žฅ์ž๋ฆฌ๋ณด๋‹ค ์ ๊ฒŒ ๊ธฐ๋‹ค๋ฆผ)

 

4) C-SCAN (Circular SCAN)

- ๋‹ค๋ฅธ์ชฝ ๋์— ๋„๋‹ฌํ–ˆ์œผ๋ฉด ํ์— ์žˆ๋Š” ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜์ง€ ์•Š๊ณ  ๊ณง๋ฐ”๋กœ ์ถœ๋ฐœ์ ์œผ๋กœ ๋‹ค์‹œ ์ด๋™

- ์ด๋™ ๊ฑฐ๋ฆฌ๋Š” ๊ธธ์–ด์งˆ ์ˆ˜ ์žˆ์ง€๋งŒ SCAN๋ณด๋‹ค ๊ท ์ผํ•œ ๋Œ€๊ธฐ ์‹œ๊ฐ„์„ ์ œ๊ณตํ•œ๋‹ค

 

5) N-SCAN 

- ์ผ๋‹จ disk head๊ฐ€ ํ•œ ๋ฐฉํ–ฅ์œผ๋กœ ์›€์ง์ด๊ธฐ ์‹œ์ž‘ํ•˜๋ฉด ๊ทธ ์‹œ์ ์— ๋“ค์–ด์˜จ ์š”์ฒญ์€ ๋˜๋Œ์•„์˜ฌ ๋•Œ ์ฒ˜๋ฆฌ

* SCAN : ๊ฐ€๋Š” ๋„์ค‘์— ๋“ค์–ด์˜จ ์š”์ฒญ๋„ ์ฒ˜๋ฆฌ

 

6) LOOK & C-LOOK

- head๊ฐ€ ์ง„ํ–‰ ์ค‘์ธ ๋ฐฉํ–ฅ์— ๋” ์ด์ƒ ๊ธฐ๋‹ค๋ฆฌ๋Š” ์š”์ฒญ์ด ์—†์œผ๋ฉด ํ—ค๋“œ์˜ ์ด๋™ ๋ฐฉํ–ฅ์„ ์ฆ‰์‹œ ๋ฐ˜๋Œ€๋กœ ๋Œ๋ฆผ

 

Disk Scheduling Algorithm์˜ ๊ฒฐ์ •

1) SCAN, C-SCAN ๊ธฐ๋ฐ˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์‚ฌ์šฉ: LOOK, C-LOOK ๋“ฑ์ด ์ผ๋ฐ˜์ ์œผ๋กœ DISK I/O๊ฐ€ ๋งŽ์€ ์‹œ์Šคํ…œ์—์„œ ํšจ์œจ์ 

2) File์˜ ํ• ๋‹น ๋ฐฉ๋ฒ•์— ๋”ฐ๋ผ ๋””์Šคํฌ ์š”์ฒญ์ด ์˜ํ–ฅ์„ ๋ฐ›๋Š”๋‹ค

  - ์—ฐ์† ํ• ๋‹น : ์ด๋™ ๊ฑฐ๋ฆฌ๊ฐ€ ๋” ์ค„์–ด๋“ ๋‹ค

  - ์‚ฐ๋ฐœ์  ํ• ๋‹น : ์ด๋™ ๊ฑฐ๋ฆฌ ์ฆ๊ฐ€

3) mergeํ•ด์„œ ํ•œ๊บผ๋ฒˆ์— ์ฒ˜๋ฆฌํ•จ์œผ๋กœ์จ disk I/O์˜ ํšจ์œจ์„ ๋†’์ธ๋‹ค

4) ํ•„์š”ํ•  ๊ฒฝ์šฐ ๋‹ค๋ฅธ ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ์‰ฝ๊ฒŒ ๊ต์ฒดํ•  ์ˆ˜ ์žˆ๋„๋ก OS์™€ ๋ณ„๊ฐœ์˜ ๋ชจ๋“ˆ๋กœ ์ž‘์„ฑ

 

Swap-Space Management

1. DISK๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋‘ ๊ฐ€์ง€ ์ด์œ 

1) ๋ฉ”๋ชจ๋ฆฌ์˜ ํœ˜๋ฐœ์„ฑ(volatile)

- file system ์ฒ˜๋Ÿผ ์˜์†์ ์œผ๋กœ ๋ฐ์ดํ„ฐ ์œ ์ง€ํ•˜๋Š” ๊ฒฝ์šฐ DRAM์ด ์•„๋‹Œ DISK์— ์ €์žฅํ•ด์•ผ ํ•œ๋‹ค

 

2) ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰์„ ์œ„ํ•œ memory ๊ณต๊ฐ„ ๋ถ€์กฑ

- ๋ฌผ๋ฆฌ์  ๋ฉ”๋ชจ๋ฆฌ ๋ฐ DRAM ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„ ๋ถ€์กฑ (high multiprogramming degree)

- ๋ฉ”๋ชจ๋ฆฌ์˜ ์—ฐ์žฅ ๊ณต๊ฐ„์œผ๋กœ DISK๋ฅผ ์‚ฌ์šฉํ•˜๋ฉฐ, swap area์˜ ์šฉ๋„๋กœ ์“ฐ์ธ๋‹ค

 

2. Swap-space

1) virtual memory system์—์„œ๋Š” DISK๋ฅผ memory์˜ ์—ฐ์žฅ ๊ณต๊ฐ„์œผ๋กœ ์‚ฌ์šฉ

 

2) file system ๋‚ด๋ถ€์— ๋‘˜ ์ˆ˜๋„ ์žˆ์œผ๋‚˜ ๋ณ„๋„์˜ partition ์‚ฌ์šฉ์ด ์ผ๋ฐ˜์ ์ž„

- swap area์— ์ €์žฅ๋˜๋Š” ๋ฐ์ดํ„ฐ๋“ค์€ ํ”„๋กœ๊ทธ๋žจ์ด ๋๋‚˜๋ฉด ์‚ฌ๋ผ์ง€๋Š” ๋‚ด์šฉ (๊ณต๊ฐ„ ํšจ์œจ์„ฑ < ์‹œ๊ฐ„ ํšจ์œจ์„ฑ)

- ์ผ๋ฐ˜ ํŒŒ์ผ๋ณด๋‹ค ํ›จ์”ฌ ์งง์€ ์‹œ๊ฐ„๋งŒ ์กด์žฌํ•˜๊ณ  ์ž์ฃผ ์ฐธ์กฐ๋จ

- ์ซ“๊ฒจ๋‚  ๋•Œ๋„ ๊ฐ€๋Šฅํ•œ ๋น ๋ฅด๊ฒŒ DISK์—์„œ ์จ์ค˜์•ผ ํ•จ

- page fault๊ฐ€ ๋‚˜์„œ swap area์— ์žˆ๋Š” ๊ฒƒ์„ MEM์— ์˜ฌ๋ฆด ๋•Œ๋„ ๋น ๋ฅด๊ฒŒ ์˜ฌ๋ ค์•ผ ํ•จ

 

3) ๋””์Šคํฌ์— ์ ‘๊ทผํ•˜๋Š” ๋Œ€๋ถ€๋ถ„์˜ ์‹œ๊ฐ„์€ seek time

> seek time ์ค„์ด๊ธฐ ์œ„ํ•ด ํฐ ๋‹จ์œ„๋กœ swap area์— ์˜ฌ๋ฆฌ๊ณ  ๋‚ด๋ฆผ (๋ณดํ†ต 512KB)

 

RAID (Redundant Array of Independent Disks)

์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋””์Šคํฌ๋ฅผ ๋ฌถ์–ด์„œ ์‚ฌ์šฉ

 

์‚ฌ์šฉ ๋ชฉ์ 

1. DISK ์ฒ˜๋ฆฌ ์†๋„ ํ–ฅ์ƒ

- ์—ฌ๋Ÿฌ DISK์— block์˜ ๋‚ด์šฉ์„ ๋ถ„์‚ฐ ์ €์žฅ

- ๋ณ‘๋ ฌ์ ์œผ๋กœ ์ฝ์–ด ์˜ด(interleaving, striping)

 

2. ์‹ ๋ขฐ์„ฑ (reliability)์˜ ํ–ฅ์ƒ

- ๋™์ผ ์ •๋ณด๋ฅผ ์—ฌ๋Ÿฌ ๊ฐœ์˜ DISK์— ์ค‘๋ณต ์ €์žฅ

- ํ•˜๋‚˜์˜ DISK๊ฐ€ ๊ณ ์žฅ ์‹œ ๋‹ค๋ฅธ DISK์—์„œ ์ฝ์–ด์˜ด (mirroring, shadowing)

- ๋‹จ์ˆœํ•œ ์ค‘๋ณต ์ €์žฅ์ด ์•„๋‹ˆ๋ผ ์ผ๋ถ€ DISK์— parity๋ฅผ ์ €์žฅํ•˜์—ฌ ๊ณต๊ฐ„์˜ ํšจ์œจ์„ฑ์„ ๋†’์ผ ์ˆ˜ ์žˆ๋‹ค

 

* parity

์ค‘๋ณต ์ €์žฅ์˜ ์–‘์„ ๋‚ฎ์ถ”๊ณ , ์˜ค๋ฅ˜๊ฐ€ ์ƒ๊ฒผ์„ ๋•Œ ์ด๋ฅผ ์ฒดํฌํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•จ

ex) hash ํ•จ์ˆ˜

๋Œ“๊ธ€