5. Storage and other I/O
5์ฅ Storage and Other I/O Topics ๊ฐ์
์ปดํจํฐ ์์คํ ์์ I/O๋ ๋์คํฌ, ๋คํธ์ํฌ, ๊ทธ๋ํฝ ๋ฑ ์ธ๋ถ ์ธ๊ณ์ ๋ฐ์ดํฐ๋ฅผ ์ฃผ๊ณ ๋ฐ๋ ๋ชจ๋ ์ฅ์น๋ฅผ ์๋ฏธํ๋ค. ์ด ์ฅ์์๋ I/O์ ๊ธฐ๋ณธ ๊ฐ๋ , Dependability(์์กด์ฑ), Interrupt/Polling/DMA์ ์ ์ก ๋ฐฉ์, RAID ๊ตฌ์ฑ๊น์ง ๋ค๋ฃฌ๋ค.
Introduction
I/O ์ฅ์น๋ ๋ค์ ์ธ ๊ฐ์ง ์ถ์ผ๋ก ํน์ฑํ๋๋ค.
- Behavior: input, output, input/output, or storage
- Partner: human, machine
- Data rate: byte/sec, transfer/sec
I/O Bus Connections
[Processor]โโโ[TLB / PA / Cache]
โ
[Memory-I/O Interconnect]
โ
โโโโโโโผโโโโโโฌโโโโโโโฌโโโโโโโโโโ
Main I/O I/O I/O
memory controller controller controller
โ โ โ
Disk Graphics Network
output
Interrupt๋ event ๋ฐ์ ์ Processor๋ก ์ ๋ฌ๋๋ค.
Diverse I/O Devices (Data rate ๋น๊ต)
| Device | Behavior | Partner | Data rate (Mbit/sec) |
|---|---|---|---|
| Keyboard | input | human | 0.0001 |
| Mouse | input | human | 0.0038 |
| Voice input | input | human | 0.2640 |
| Sound input | input | machine | 3.0000 |
| Graphics display | output | human | 800~8000 |
| Network/LAN | input/output | machine | 100~10000 |
| Optical disk | storage | machine | 80~220 |
| Flash memory | storage | machine | 32~200 |
| Magnetic disk | storage | machine | 800~3000 |
Dependability (์์กด์ฑ)
์์คํ ์ด ์ง์ ๋ ์๋น์ค๋ฅผ ์ ๋ขฐ์ฑ ์๊ฒ ์ ๊ณตํ๋ ๋ฅ๋ ฅ. ๋ค์ ๋ ์ํ ์ฌ์ด๋ฅผ ์๋ณตํ๋ค.
Service accomplishment โ (Failure / Restoration) โ Service interruption
(specified service) (deviation from specified)
- Fault: Component๊ฐ failure๋ฅผ ์ผ์ผํค๋ ๊ฒ โ System failure๋ก ์ด์ด์ง ์๋/์ด์ด์ง์ง ์์์๋ ์์. System์ด down๋ ์ ์์.
- Noise, ๊ณต์ ์ ๋ฌธ์ โ Error. ๋๋ถ๋ถ์ SW error๊ฐ ๋ง์.
Dependability Measures
- Reliability (์ ๋ขฐ๋): failure๊น์ง์ ์๊ฐ โ MTTF (Mean Time To Failure)
- Service Interruption: failure ๋ฐ์ ํ ๊ณ ์น๋ ์๊ฐ โ MTTR (Mean Time To Repair)
- MTBF (Mean Time Between Failures) = MTTF + MTTR (failure ์ฌ์ด์ ์๊ฐ)
- Availability (์ด์ฉ๋ฅ ):
$$\text{Availability} = \frac{\text{MTTF}}{\text{MTBF}}$$
MTTF ํฅ์ ๋ฐฉ๋ฒ โ ์์ธกํ์ฌ ํํผ
- Fault avoidance: ํผํ๊ธฐ
- Fault tolerance: Fault๊ฐ ๋๋ failure๋ก ๊ฐ์ง ์๊ฒ (์ฌ๋ฌ ๊ฐ ๋ง๋ค์ด ๋๊ณ ์ฌ์ฉ, redundancy)
- Fault forecasting: ์์ธก
MTTR ์ค์ด๋ ๋ฐฉ๋ฒ
Failure๋ฅผ ์ง๋จํ๊ณ ์๋ฆฌํ๋ ํด์ด๋ ํ๋ก์ธ์๋ฅผ ํฅ์์ํค๊ธฐ.

I/O Management
I/O Commands โ I/O Controller Registers
๊ฐ I/O ์ฅ์น๋ command register, status register, data register๋ฅผ ๊ฐ์ง๋ค. CPU๊ฐ ์ด ๋ ์ง์คํฐ์ read/writeํ์ฌ ์ฅ์น๋ฅผ ์ ์ดํ๋ค.
- Command register: I/O controller์๊ฒ ์ด๋ค ์ผ์ ํ ์ง ์ง์
- Status register: I/O ์๋ฃ ์ฌ๋ถ, error ์ฌ๋ถ ๋ฑ
- Data register: ์ฃผ๊ณ ๋ฐ์ ๋ฐ์ดํฐ (read/write)
I/O Register Mapping (๋ฉ๋ชจ๋ฆฌ ์ ์ถ๋ ฅ ๋งคํ)
I/O controller register๋ฅผ ๋ฉ๋ชจ๋ฆฌ ์ฃผ์ ๊ณต๊ฐ์ ๋งคํํด์ ์ผ๋ฐ load/store ๋ช ๋ น์ด๋ก I/O ์ ์ด. ์ด๋ฅผ memory-mapped I/O๋ผ๊ณ ํจ.
- ๋ฉ๋ชจ๋ฆฌ์ I/O register๊ฐ ๊ฐ์ address space ๊ณต์
- CPU ์ธํฐํ์ด์ค ๋ณต์ก๋ ๊ฐ์
Polling
CPU๊ฐ status register๋ฅผ ์ฃผ๊ธฐ์ ์ผ๋ก checkํด I/O ์ฅ์น์ ์ํ๋ฅผ ํ์ธ.
- ์ฅ์ : ๊ตฌํ ๊ฐ๋จ
- ๋จ์ : CPU resource ๋ญ๋น (๋ค๋ฅธ ์ผ ๋ชปํจ)

Interrupts
Device์ ready๋ error ๋ฐ์ ์ status register๋ฅผ CPU๊ฐ ์ฒดํฌ X, interrupt controller๊ฐ ์ฒดํฌ. Event ๋ฐ์ ์ CPU์๊ฒ ์๋ ค์ค.
Interrupt vs Exception
Interrupt๋ exception๊ณผ ์ ์ฌ (์ฒ๋ฆฌ ๋ฐฉ์์ด ์ ์ฌํ๊ธฐ ๋๋ฌธ์). ์ฃผ๋ก I/O์ ์ํด ๋ฐ์.
- Interrupt๋ instruction์ ์ํ๊ณผ ๋๊ธฐํ๋์ง ์์ (ํ์ฌ ์ํํ๋ ๊ฒ๊ณผ ๊ด๊ณ X)
- Instruction ์ฌ์ด์์ handler๊ฐ ๊ฐ์ ๊ฐ๋ฅ (Instruction ์ํ ์ค ๋๋ ๊ฒ ์๋, instruction์ด ๋๋๊ณ ๋ค์ instruction ์ํ ์ interrupt ์ฒ๋ฆฌ)
- Interrupt signal์ ํ ๊ฐ๋ง ์กด์ฌ โ CPU๊ฐ interrupt๋ฅผ ๋ฐ์์ํจ ๊ฒ์ ์ฐพ์ ์ฒ๋ฆฌ
Priority Interrupt
๊ธด๊ธํ ์ฒ๋ฆฌ๊ฐ ํ์ํ device๋ค์ด ๋ ๋์ ์ฐ์ ์์๋ฅผ ๊ฐ์ง. ๋ฎ์ ์ฐ์ ์์์ interrupt ์ํ ์ค์๋ ์ํ ๊ฐ๋ฅ.
I/O ์ฒ๋ฆฌ๋ Interrupt ์ฒ๋ฆฌ์ ๊ฐ๋ค.
I/O Data Transfer (Data register์ Memory ์ฌ์ด์์ ์ผ์ด๋๋ ์ผ)
โ Polling & Interrupt-Driven I/O
CPU๊ฐ I/O์ Data register ์ฌ์ด์์ ๋ฐ์ดํฐ๋ฅผ ์ฝ๊ณ ์ โ CPU๊ฐ ์ํํ๊ธฐ์ ์๊ฐ์ ๋ง์ด ์๋ชจ.
์: Page fault ์ CPU โ Command register โ HDD I/O Controller (HDD Data โ data R) โ CPU (data R โ Memory์ ํ ์์ญ). ์ด ๊ณผ์ ์ด CPU ๋ญ๋น โ DMA๋ก ๋์ ํ๊ฒ ๋จ.
โก DMA (Direct Memory Access)
์ผ์ข ์ I/O, Command R & Status R ์กด์ฌ. But data R์ ๋ณดํต ์กด์ฌ X.
HDD I/O Controller๊ฐ ์ฝํ ๋ฐ์ดํฐ๋ฅผ data R โ Memory์ ํ ์์ญ์ผ๋ก ์ฎ๊ธฐ๋ ์ญํ .
- OS๊ฐ DMA์๊ฒ Starting address, Size, ๋์ I/O controller ์ ๋ณด๋ฅผ DMA์ Command register๋ฅผ ํตํด ์๋ ค์ฃผ๋ฉด DMA๊ฐ ์ญํ ์ํ
- Special I/O Controller (data R๊ฐ ์๊ธฐ ๋๋ฌธ)
- Error ๋ฐ์ ์, interrupt๋ฅผ ํตํด CPU์๊ฒ ์๋ ค์ค โ interrupt controller๊ฐ ์์ผ๋ฉด ๊ทธ๊ฒ์ ํตํด

DMA์ Cache/VM Interaction
DMA/Cache Interaction
DMA๊ฐ cached location์ ์ฝ์ ๋, Memory๋ ์ต์ ์ด ์๋ ์ ์์ (cache์ dirty) โ Cache๋ฅผ flush ํด์ผ ํจ.
- DMA๊ฐ cached location์ write โ Cache์ copy๋ stale (๋ฌดํจํ ํ์)
- Cached location์ ์๋ชป ์ฝ์ง ์๋๋ก flushing ํ์
ํด๊ฒฐ
- DMA๊ฐ ์์๋๊ธฐ ์ ํด๋น ๋ฌผ๋ฆฌ ๋ฉ๋ชจ๋ฆฌ ์์ญ์ Flushing (cache์ dirty data ์์ผ๋ฉด memory๋ก write-back)
- DMA ๋๋ ํ, invalidate (cache์ stale copy ๋ฌดํจํ)
- Non-cacheable region์ผ๋ก ์ง์ ํ ์๋ ์์
DMA/VM Interaction
OS virtual memory ํ๊ฒฝ์์ DMA๋ physical address ๊ธฐ์ค์ผ๋ก ๋์.
- VM์ ํ page๊ฐ ์ฌ๋ฌ frame์ ๊ฑธ์น ์ ์์ โ DMA๋ page ๋จ์๋ก ๋ถํ ํด์ ์ ์กํด์ผ ํจ
- Use multiple handlers / physical page๋ ์ฌ๋ฌ ๋ฒ ๋๋ ์ ์ฒ๋ฆฌ

์ ์ฒด ์๋๋ฆฌ์ค โ ํ๋ก๊ทธ๋จ ์คํ ์ค DMA ๋์
๋ค์์ ๋ ํ๋ก์ธ์ค P0, P1์ด ๋์ํ๊ณ DMA๊ฐ I/O๋ฅผ ์ํํ๋ ์ ์ฒด ํ๋ฆ:
- P0 ์คํ โ Timer ์ค์
- TLB Miss โ exception โ TLB ์ ๋ฐ์ดํธ
- Page fault โ DMA์๊ฒ ๋ช ๋ น ์ ๋ฌ
- OS๊ฐ DMA command register์ ๋ช ๋ น ์์ฑ (kernel โ ์ซ๊ฒจ๋์ง X)
- DMA ์์ ์ค Context Switching (P0 โ P1)
- P1 ์คํ (TLB miss ๋์ง๋ง DRAM์ ์๊ธฐ์ ๊ณ์ ์ฌ์ฉ)
- DMA ์ผ์ ๋ค ํจ โ Interrupt Controller๊ฐ OS์ ์๋ฆผ
- P1์ ์๊ฐ์ด ๋จ์์ ๊ณ์ ์ฌ์ฉ
- P1 ์๊ฐ์ด ๋๋์ P0์ ์ ์ด๊ถ ์ค โ TLB Hit โ PA ๋ณ๊ฒฝ โ Cache โ Data ์ฌ์ฉ
- OS๊ฐ ๋ช ๋ น (SA+VA) โ HDD I/O Controller โ HDD
์ด๋ฐ ์์ผ๋ก DMA, Timer, TLB, Page table, Cache๊ฐ ๋ณตํฉ์ ์ผ๋ก ์๋.

RAID (Redundant Array of Inexpensive Disks)
๋์คํฌ ์ฌ๋ฌ ๊ฐ๋ฅผ ๋ฌถ์ด ์ ๋ขฐ์ฑ + ์ฑ๋ฅ์ ๋์์ ์ป๋ ๊ธฐ๋ฒ.
RAID 0 (Striping)
- ๋ฐ์ดํฐ๋ฅผ ์ฌ๋ฌ disk์ ๋๋์ด ์ ์ฅ (stripe)
- ์ฅ์ : ์ฑ๋ฅ โ (๋ณ๋ ฌ read/write)
- ๋จ์ : redundancy ์์ โ ํ๋ ๊ณ ์ฅ๋๋ฉด ๋ฐ์ดํฐ ์์ค
RAID 1 (Mirroring)
- ๋์ผ ๋ฐ์ดํฐ๋ฅผ ๋ disk์ ๋ณต์
- ์ฅ์ : Reliability โ (ํ๋ ๊ณ ์ฅ๋๋ ๋ค๋ฅธ ์ชฝ ์ฌ์ฉ)
- ๋จ์ : ์ฉ๋ ์ ๋ฐ, ๋น์ฉ โ
RAID 2, 3 (์ด์ RAID)
- Bit-level / Byte-level parity (์ ์ ์)
RAID 4 (Block-Interleaved Parity)
- Block stripe + ๋ณ๋ parity disk 1๊ฐ
- ์ฝ๊ธฐ๋ ๋ณ๋ ฌ ๊ฐ๋ฅ, ์ฐ๊ธฐ๋ parity disk๊ฐ bottleneck
RAID 5 (Block-Interleaved Distributed Parity)
- RAID 4์ Parity Disk๋ฅผ ์ ๊ฑฐ ํ, ๋ชจ๋ Disk์ ๋๋์ด ์ ์ฅ
- ๋ณ๋ ฌ์ ์ธ service๊ฐ ๊ฐ๋ฅํด์ง
- ์ผ๋ถ ๊ฒฝ์ฐ์์๋ง ๊ฐ๋ฅ, ๋น์ฉ์ RAID 4์ ๋์ผ, Write์ ์ฑ๋ฅ โ (RAID 4 < RAID 5)
์:
0 1 2 3 4
Stripe Unit D0 D1 D2 D3 P
D4 D5 D6 P D7
D8 D9 P D10 D11
D12 P D13 D14 D15
P D16 D17 D18 D19
- Disk 0๊ณผ Disk 1 ๋์์ ์ ๋ฐ์ดํธ ๊ฐ๋ฅ โ ๋ค์ Disk 0, 1, 3, 4 ์ฌ์ฉ
- Disk 0๊ณผ Disk 4 ๋์์ ์ ๋ฐ์ดํธ X (parity ์ถฉ๋) โ Disk 4 ๋ ์ฌ์ฉ X
RAID 6 (P+Q Redundancy)
- 2๊ฐ์ parity๋ฅผ ์ฌ์ฉํ์ฌ 2๊ฐ์ error์ ๋ํด ๋ณต๊ตฌํด์ค (Reed-Solomon Codes)
- Parity P & Q โ Data ์ ๋ฐ์ดํธ ์ 6๋ฒ์ I/O๊ฐ ํ์
- ์ ๋ขฐ๋๊ฐ ์ค์ํ ํ๊ฒฝ์์ ์ฌ์ฉ
Hot swapping: HDD ๊ต์ฒด ์ ์ ์์ ๋์ง ์๊ณ ๊ต์ฒด.

์ ๋ฆฌ
| ๊ฐ๋ | ํต์ฌ |
|---|---|
| Dependability | Reliability, Availability โ MTTF/MTTR/MTBF |
| Polling | CPU๊ฐ status register ์ฃผ๊ธฐ์ ๊ฒ์ฌ |
| Interrupt | Device ์ด๋ฒคํธ ์ CPU์ signal |
| DMA | CPU ์์ด ๋ฉ๋ชจ๋ฆฌ-I/O ์ง์ ์ ์ก |
| RAID 0 | Striping โ ์ฑ๋ฅ โ |
| RAID 1 | Mirroring โ ์ ๋ขฐ์ฑ โ |
| RAID 5 | Distributed parity โ ์ฑ๋ฅ+์ ๋ขฐ์ฑ ๊ท ํ |
| RAID 6 | P+Q redundancy โ 2๊ฐ fault ํ์ฉ |
I/O๋ CPU ๊ด์ ์์ ๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ๋ณด๋ค ํจ์ฌ ๋๋ฆฌ๊ธฐ ๋๋ฌธ์ CPU๋ฅผ ์ต๋ํ ํ์ฉํ๊ธฐ ์ํ ๋น๋๊ธฐ ๊ธฐ๋ฒ(interrupt, DMA) ๊ณผ ๋ค์ค ๋์คํฌ๋ฅผ ํ์ฉํ ์ ๋ขฐ์ฑ(RAID) ์ด ํต์ฌ์ด๋ค.
Comments (0)
No comments yet. Be the first to comment!
Please to write a comment.