[์šด์˜์ฒด์ œ] ๊ธฐ๋ง๊ณ ์‚ฌ Summary

2023. 7. 21. 00:32ใ†ComputerScience/OperatingSystem

 

 

 

 

9. main memory 

- memory management ๋ชฉํ‘œ – provide a convenient abstraction for programming (์ธํ„ฐํŽ˜์ด์Šค)

- Batch programming 

– program์ด ์ง์ ‘ physical address๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. 

- process ํ•˜๋‚˜๋งŒ ์žˆ๋˜ ์‹œ์ ˆ์—๋Š” ์ƒ๊ด€ ์—†์—ˆ์Œ -> multiple process – ๋ฉ”๋ชจ๋ฆฌ ๊ด€๋ฆฌ์˜ ํ•„์š”์„ฑ ๋ฐœ์ƒ

 

- ๋ฌธ์ œ์  1) multiple process 2) ๋ฉ”์ธ ๋ฉ”๋ชจ๋ฆฌ๋ณด๋‹ค ํฐ ํ”„๋กœ์„ธ์Šค (ex) ๊ฒŒ์ž„)

-> Virtual memory ๋“ฑ์žฅ
: process 
๋‚ด๋ถ€์—์„œ๋Š” virtual, logical address ์‚ฌ์šฉ, ์‹ค์ œ RAM์˜ ์ฃผ์†Œ๋Š” physical address 

- secondary storage, memory๋ฅผ main memory์ฒ˜๋Ÿผ ๊ฐ€์ ธ์™€์„œ ์‚ฌ์šฉํ•จ

- ์‹ค์ œ ๋ฉ”๋ชจ๋ฆฌ๋Š” ๋ฌดํ•œํ•˜๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๊ณ  ํ”„๋กœ๊ทธ๋žจ ๊ฐœ๋ฐœ, OS๊ฐ€ ์ด๋Ÿฌํ•œ ๊ธฐ๋Šฅ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๋Š” ๊ฒƒ

 

* ์–ธ์ œ logical address์™€ physical address๋ฅผ binding ํ•ด์•ผ ํ• ๊นŒ? (address binding time)

- compile time / load time / execution time  ์‹คํ–‰ ์‹œ๊ฐ„์— binding

 

1) compile time – logical address๋ฅผ ์‹ค์ œ RAM ์ฃผ์†Œ์— compile time์— ์—ฐ๊ฒฐ -> ๊ณ ์ •์ ์œผ๋กœ ํ•ด๋‹น ์˜์—ญ(๋ฌผ๋ฆฌ์ ) ์—์„œ๋งŒ ํŠน์ • process๊ฐ€ ์ˆ˜ํ–‰๋จ  ๋‚˜๋จธ์ง€ ์˜์—ญ์€ ๋‚ญ๋น„๋  ์ˆ˜ ์žˆ๋‹ค  ํŠน์ • ๋ฉ”๋ชจ๋ฆฌ์—์„œ๋งŒ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋Œ์•„๊ฐ

- batch system (์•„๋‘์ด๋…ธ) – ํ•˜๋‚˜์˜ ํ”„๋กœ๊ทธ๋žจ๋งŒ ์ˆ˜ํ–‰๋˜๋Š” ํ™˜๊ฒฝ์€ okay

2) Load time – ๋กœ๋”ฉ ์‹œ, ์‹œ๊ฐ„์ด ๋งŽ์ด ๊ฑธ๋ฆผ  ์˜ค๋ฒ„ํ—ค๋“œ๊ฐ€ ๋งŽ์•„ ์‚ฌ์šฉ X

 

3) Execution time – ํ˜„์žฌ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

- logical address๊ฐ€ ๊ทธ๋Œ€๋กœ ์˜ฌ๋ผ๊ฐ„ ๋’ค, ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค์˜ ๋ช…๋ น์–ด๊ฐ€ ์‹คํ–‰๋  ๋•Œ, ๊ทธ์ œ์„œ์•ผ base address + a๋กœ physical address๊ฐ€ ๊ณ„์‚ฐ๋จ (binding)

 

Address mapping – MMU (memory management unit) 
– CPU 
๋‚ด์—์„œ virtual(ํ”„๋กœ๊ทธ๋žจ ๋‚ด๋ถ€์—์„œ ์‚ฌ์šฉ), physical address(์‹ค์ œ RAM ์ฃผ์†Œ) ๋ณ€ํ™˜์‹œํ‚ค๋Š” ํ•˜๋“œ์›จ์–ด ์žฅ์น˜

- ๋‘˜ ์‚ฌ์ด์˜ ๋ณ€ํ™˜์„ ํ•  ๋•Œ, CPU๋‚ด์˜ MMU๋ผ๋Š” ๋กœ์ง์—์„œ translation์„ ํ•ด์ค€๋‹ค.

+ Swap – RAM์— ์กด์žฌํ•˜๋Š” ์ผ๋ถ€๋ถ„์„ secondary storage์— ์ €์žฅ, ๋ฌดํ•œ ๋ฉ”๋ชจ๋ฆฌ์ฒ˜๋Ÿผ ๋ณด์ผ ์ˆ˜ ์žˆ๋‹ค. (10์žฅ)

 

- logical address space = ์„œ๋กœ ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๊ฐ€ ๋™์‹œ์— application์„ ์‹คํ–‰ -> ๋™์ผํ•œ ์ฃผ์†Œ ๊ฐ’

: ๋‹ค๋ฅธ Physical address์— ๋งคํ•‘ ๋˜๋”๋ผ๋„, ํ”„๋กœ๊ทธ๋žจ ๋‚ด๋ถ€์˜ logical address๋Š” ๋™์ผํ•˜๋‹ค

 

1. Contiguous allocation – logically contiguous => physically contiguous (๊ฐ€์žฅ ๋‹จ์ˆœํ•˜๊ณ  ์‰ฌ์šด ๋ฐฉ๋ฒ•, ์‚ฌ์šฉX)

- physical address = logical address + base address (relocation register)

+ ๋ฉ”๋ชจ๋ฆฌ ๋ณดํ˜ธ: ๋‚ด๊ฐ€ ์ฐธ์กฐํ•  ์ˆ˜ ์žˆ๋Š” ์˜์—ญ์ด ์•„๋‹ˆ๋ผ๋ฉด exception, fault -> OS (limit register๋ณด๋‹ค ์ž‘์€ ๊ฐ’๋งŒ)

* access time ์ธก๋ฉด์—์„œ ์„ฑ๋Šฅ์€ ๊ฐ€์žฅ ์ข‹๋‹ค. 

 

-> ์—ฌ๋Ÿฌ process๋ฅผ ๋Œ๋ฆฌ๋ฉฐ, hole์ด ๋ฐœ์ƒ -> first fit(๊ฐ€๋Šฅํ•œ ์ฒซ๋ฒˆ์งธ), best fit(๊ฐ€์žฅ ์งœํˆฌ๋ฆฌ ์ž‘์€ ๊ฒƒ์— ๋ฐฐ์น˜) // 

Worst fit(๊ฐ€์žฅ ํฐ hole์ด ๋‚จ๋Š” ๊ฒƒ์— ๋ฐฐ์น˜)์€ ๋‹ค๋ฅธ ๋‘ ๋ฐฉ๋ฒ•์— ๋น„ํ•ด ์„ฑ๋Šฅ์ด ๋–จ์–ด์ง // ํ•˜์ง€๋งŒ ์ด๋ ‡๊ฒŒ ํ•ด๋„ 

* External Fragmentation – ๋‹จํŽธํ™” (hole์˜ ์žํˆฌ๋ฆฌ ์กฐ๊ฐ), ํ™€์ด ์ž‘์•„์ ธ์„œ ๋”์ด์ƒ ์‚ฌ์šฉ๋˜์ง€ ์•Š์Œ

- compaction์œผ๋กœ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, HDD๋กœ ์˜ฎ๊ธฐ๊ณ  ๋‹ค์‹œ copyํ•˜๋Š” ๊ณผ์ •์—์„œ I/O overhead๊ฐ€ ๋งค์šฐ ํผ 

 

2. Paging – logically contiguous, but physically not contiguous

- logical memory๋ฅผ page ๋‹จ์œ„๋กœ, physical memory๋ฅผ frame ๋‹จ์œ„๋กœ ์ž๋ฆ„ (๋ณดํ†ต 4KB)

- ๋”์ด์ƒ external fragmentation์€ ๋ฐœ์ƒX, internal fragmentation์€ O -> ๊ทธ๋Ÿฌ๋‚˜ ๋น„๊ต์  ๋งค์šฐ ์ž‘์Œ

 

* ์ฃผ์†Œ ๋ณ€ํ™˜ - <page number + offset> (p, d) -> <frame number + offset> (f, d) 

- page table์€ OS๊ฐ€ ๊ด€๋ฆฌํ•œ๋‹ค, (p, d) -> (f, d) // ์ด๋•Œ offset์€ ์œ ์ง€๋˜๋Š”๋ฐ, ์ด๊ฒŒ page ํฌ๊ธฐ๋งŒํผ ํ• ๋‹น

(ํ•œ ํŽ˜์ด์ง€ ๋‚ด๋ถ€์—์„œ ์–ด๋Š ์œ„์น˜์ธ์ง€ ๊ฒฐ์ •ํ•˜๋Š” ๊ฐ’์ด๋‹ˆ๊นŒ)

- page table์€ page number -> frame number ๋กœ mapping ์‹œํ‚ค๋Š” ์—ญํ•  (offset์€ ๋™์ผ)

- page table์€ Process ๋ณ„๋กœ ์กด์žฌํ•œ๋‹ค!

 

* page example – logical address – 32bit, physical address – 20bit, page size 4KB(12bit)

-> offset 12 bit, page number 20bit (32 – 12) // frame number = 8 bit

Page table entries = 2^20๊ฐœ (page number ์ˆ˜ ๋งŒํผ) // ์ € ํ…Œ์ด๋ธ” ๊ฐ’์ด Int -> 4MB(CPU ๋‚ด์˜ MMU์— ๋‘˜ ์ˆ˜ X, ๋ฉ”์ธ ๋ฉ”๋ชจ๋ฆฌ์— ๋‘”๋‹ค. ๋ฉ”์ธ ๋ฉ”๋ชจ๋ฆฌ์— 2๋ฒˆ ์ ‘๊ทผ -> ์„ฑ๋Šฅ์ด 2๋ฐฐ ๋‚˜๋น ์ง„ ๊ฒƒ)

- Free frame – ํ˜„์žฌ ํ• ๋‹น๋˜์ง€ ์•Š์€ frame ๊ด€๋ฆฌ 

 

* Associative memory – parallel search == CAM(content addressable memory)

- TLB (translation look-aside buffer) -> ์–˜๋„ process ๋ณ„ ์กด์žฌ, MMU(์ฆ‰ CPU)๊ฐ€ ๊ด€๋ฆฌ

- two memory accesses ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด, TLB(์บ์‰ฌ ๋ฉ”๋ชจ๋ฆฌ)๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

- page number๋ฅผ ์ฃผ๋ฉด, parallelํ•˜๊ฒŒ ์ซ™ ์„œ์น˜, ๋ฐ”๋กœ frame number๊ฐ€ ํŠ•๊ฒจ์ ธ ๋‚˜์˜ค๋Š”, ํŠน๋ณ„ํ•œ ์บ์‰ฌ ๋ฉ”๋ชจ๋ฆฌ 

* TLB = locality (temporal locality – ์‹คํ–‰ ์‹œ๊ฐ„ ๊ด€์ , code ์˜์—ญ, loop ๊ตฌ๋ฌธ 80% vs Spatial locality – ๋‚ด๊ฐ€ ์ฐธ์กฐํ•œ ์ฃผ๋ณ€ ์˜์—ญ ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ์ฐธ์กฐ๋  ๊ฐ€๋Šฅ์„ฑ์ด ๋†’๋‹ค, data array)

 

- TLB miss – 99%๋Š” TLB hit, but ๋•Œ๋•Œ๋กœ miss -> CPU(ํ•˜๋“œ์›จ์–ด)๊ฐ€ ์•Œ์•„์„œ TLB miss ์ฒ˜๋ฆฌ

: 0.99 * 1 + 0.01 * 2 -> 1.01 

- Effective access time (EAT) = (1 + e) * a + (2 + e)(1 – a) = 2 + e – a == 1

// TLB hit ํ™•๋ฅ  = 0.99 = a, TLB miss = 1 – a, e๋Š” ๊ทธ๋ƒฅ ๋งค์šฐ ์ž‘์€ ๊ฐ’ ์˜๋ฏธ 

 

* paging์˜ memory protection (์ง€๊ธˆ๊นŒ์ง€๋Š” memory address ๊ด€๋ฆฌ) -> ์ฐธ์กฐํ•˜์ง€ ๋ชปํ•  ์˜์—ญ์„ ์–ด๋–ป๊ฒŒ ๋ณดํ˜ธ? 

- process ๋ณ„๋กœ ์กด์žฌํ•˜๋Š” page table -> frame number์™€ ํ•จ๊ป˜, valid – invalid ํ•œ ๋น„ํŠธ ํ•„์š” 

- ๋‚ด๊ฐ€ ์›ํ•˜๋Š” page์˜ frame number + invalid๋ผ๋ฉด, accessํ•  ์ˆ˜ ์—†๋‹ค. 
-> Fault, exception: CPU
๊ฐ€ ์Šค์Šค๋กœ์—๊ฒŒ ์ธํ„ฐ๋ŸฝํŠธ๋ฅผ ๊ฑด๋‹ค – OS๊ฐ€ ์ˆ˜ํ–‰๋˜์–ด ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค ์ข…๋ฃŒ์‹œํ‚ด

 

* Page table entries (PTEs)

- valid bit (V) – ๋ฉ”๋ชจ๋ฆฌ ํ”„๋กœํ…์…˜ / reference bit (R) – ์ฐธ์กฐ๋œ ์œ ๋ฌด ํ™•์ธ / modified bit (M) – ๋ณ€๊ฒฝ ์œ ๋ฌด 

Protection bit (prot) – ํ•ด๋‹น ํŽ˜์ด์ง€์— ํ—ˆ์šฉ๋œ ์—ฐ์‚ฐ์„ ์ œ์–ด, 2bit ex) read, write, exec, ect 

-> page table์— frame number๋งŒ ์žˆ๋Š” ๊ฒƒ์€ ์•„๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ, ๋‹ค๋ฅธ ๋น„ํŠธ๋“ค๋„ ๋” ์žˆ์Œ

 

- managing page tables – 32bit address space, offset 12bit, 2^20๊ฐœ์˜ entries * 4KB pages -> 4MB, 100๊ฐœ์˜ ํ”„๋กœ์„ธ์Šค -> 400MB

- ์ž‘์€ process์˜ ๊ฒฝ์šฐ, 1๊ฐœ page๋งŒ valid, ๋‚˜๋จธ์ง€ ์‹น ๋‹ค invalid -> ๋น„ํšจ์œจ

-> ๋”ฐ๋ผ์„œ page table ๊ตฌ์กฐ๋ฅผ dynamically extensibleํ•˜๊ฒŒ! -> 1. Hierarchical paging (ํ˜„์žฌ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹)

 

1. * Hierarchical paging – multiple page tables๋ฅผ ์‚ฌ์šฉ  ์›๋ž˜ frame number๋ฅผ ์ €์žฅํ•œ ์œ„์น˜์—, ๋‹ค๋ฅธ page table์˜ ์ฃผ์†Œ๊ฐ€ ์žˆ๋‹ค. 

- outer page table – 2^10 entries, 4B(32bit int์˜๋ฏธ) * 2^10 = 4KB

- page table – 2^10 entries * 2 ^ 10 = 4B(int) * 2^10 * 2^10 = 4MB (์ „์ฒด = 4KB + 4MB)

(If single level paging – 2^20 entries * 4B = 4MB) ์ค„์ธ๋‹ค๋ฉด์„œ ์™œ ๋Š˜์–ด๋‚จ? ์ตœ์•…์˜ ๊ฒฝ์šฐ์ธ ๊ฒƒ! 

 

- ํ•„์š”ํ•  ๋•Œ ๋งˆ๋‹ค ๋™์ ์œผ๋กœ ํ•˜๋‚˜์”ฉ ๋งŒ๋“œ๋Š” ๊ฒƒ

- only one page is used -> outer page table์€ 4KB๋‹ค ์กด์žฌ, but outer์—์„œ ์—ฐ๊ฒฐ๋˜๋Š” inner๊ฐ€ 2^10 entries 1๊ฐœ 

-> 2^10 * 4B = 4KB (๋”ฐ๋ผ์„œ ์ด 4KB + 4KB = 8KB๋งŒ ์žˆ์œผ๋ฉด ๋จ!) 

-> process ํฌ๊ธฐ์— ๋น„๋ก€ํ•œ page table์˜ ํฌ๊ธฐ

 

2. Hashed page table – ์˜ค๋ฒ„ํ—ค๋“œ๊ฐ€ ๋„ˆ๋ฌด ์ปค์„œ ์‚ฌ์šฉX 3. Inverted page table – frame๊ณผ page๋ฅผ ๊ฑฐ๊พธ๋กœ ๋งŒ๋“ค์ž X

 

* paging์˜ ์žฅ์  – shared memory๋ฅผ ๊ตฌํ˜„ํ•˜๊ธฐ ์ข‹๋‹ค. 

- ์„œ๋กœ ๋‹ค๋ฅธ process๊ฐ€ code์˜์—ญ์€ ๋™์ผํ•˜๊ณ , data ์˜์—ญ๋งŒ ๋‹ค๋ฅด๋‹ค -> page table์˜ ๋งˆ์ง€๋ง‰ page ์š”์†Œ๋งŒ ๋‹ค๋ฆ„

-> ๋™์ผํ•œ physical memory๋ฅผ ๋งคํ•‘ 

-> ์œ ๋‹‰์Šค-๋ฆฌ๋ˆ…์Šค์˜ shared library ๊ตฌํ˜„ ์‹œ ํ™œ์šฉ, (์œˆ๋„์šฐ๋Š” dll – dynamically linked library)

 

- paging์˜ ์žฅ์  – external fragmentation X, memory protection ์šฉ์ด

- ๋‹จ์  – 2 reference per address lookup (page table -> memory) -> TLB (cache memory)๋กœ ํ•ด๊ฒฐ!

+ ๊ณผํ•œ page table ํฌ๊ธฐ -> hierarchical page tables๋กœ ํ•ด๊ฒฐ!

 

3. Segmentation (contiguous allocation, paging ๊ทธ๋ฆฌ๊ณ  ๋งˆ์ง€๋ง‰ ๋ฐฉ๋ฒ•  ์–˜๋„ ํ˜„์žฌ ์“ฐ์ด๋Š” ๋ฐฉ๋ฒ•)

- ์˜๋ฏธ ์žˆ๋Š” ๋‹จ์œ„๋กœ ์ž๋ฅด์ž. ๋‚ด์šฉ์„ ๊ณ ๋ คํ•˜์—ฌ ๋ถ„๋ฆฌํ•˜์ž. Ex) ์ฝ”๋“œ, ๋ฐ์ดํ„ฐ, ํž™(extra), ์Šคํƒ

+ segment ๋‚ด์—์„œ contiguous allocation -> ๋‹ค์‹œ external fragmentation ๋ฌธ์ œ ๋ฐœ์ƒ! -> paging ์‚ฌ์šฉ

 

- segmentation์˜ ์žฅ์  – memory protection ์šฉ์ด (read, write, exec ๋“ฑ protection ๋น„ํŠธ ํ™œ์šฉ)

- Share segment๊ฐ€ ์šฉ์ดํ•˜๋‹ค (Code/data sharing์ด segment level์—์„œ ๊ฐ€๋Šฅ, ex shared libraries)

-> paging์˜ ์žฅ์ ๊ณผ ํ˜ผํ•ฉํ•˜์—ฌ hybrid ๋ฐฉ์‹์œผ๋กœ ์‚ฌ์šฉ, segment๋กœ ๋‚˜๋ˆ„๊ณ , ๊ทธ ๋‚ด๋ถ€์—์„œ paging์œผ๋กœ ์ž๋ฆ„

=> Hybrid approach: Paged segments // Segmentation with paging ์ด๋ผ๊ณ  ๋ถ€๋ฆ„ 

 

+ multiple page size = 4KB๋ณด๋‹ค ๋” ํฐ ํŽ˜์ด์ง€ ์‚ฌ์ด์ฆˆ๋„ ์ง€์› (ํŠน์ • ๊ฒฝ์šฐ, ํฐ 4MB page ์ง€์›)

- ARM – mobile – segmentation X, multiple page size ํ™œ์šฉ

 

 

 

 

 

10. Virtual memory 

: virtual memory that is larger than physical memory (RAM) – ์ž˜ ์•ˆ ์“ฐ๋Š” ๊ฒƒ์€ secondary๋กœ

 

* Demand Paging – ํ•„์š”ํ•œ ์‹œ์ ์— ์ด๋ฃจ์–ด์ง€๋Š” paging

- paging system with page level swapping 

: page ๋‹จ์œ„์˜ swapping -> secondary storage <-> main memory (RAM)

- page๊ฐ€ ํ•„์š”ํ•œ ์‹œ์ ์— main memory๋กœ ๋ถˆ๋Ÿฌ์˜จ๋‹ค. 

-> Locality (cache memory, TLB, demand paging, Buffer cache ๋“ฑ๋“ฑ)

- temporal locality – ์ตœ๊ทผ์— ์ฐธ์กฐ๋œ ๋ถ€๋ถ„์ด ๋‹ค์‹œ ์ฐธ์กฐ๋  ๊ฐ€๋Šฅ์„ฑ์ด ๋†’๋‹ค – x ์ถ•์œผ๋กœ ๊ธธ๊ฒŒ ํ‘œ์‹œ๋จ

- spatial locality – ์ตœ๊ทผ ์ฐธ์กฐ๋œ ๋ถ€๋ถ„์˜ ๊ทผ์ฒ˜๊ฐ€ ๊ณง ์ฐธ์กฐ๋  ๊ฐ€๋Šฅ์„ฑ์ด ๋†’๋‹ค – y ์ถ•์œผ๋กœ ๊ธธ๊ฒŒ ํ‘œ์‹œ๋จ

 

- ์™œ Demand Paging์ธ๊ฐ€? // ์ด์ „๊นŒ์ง€๋Š” ํ•ด๋‹น ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ฐธ์กฐ ๊ฐ€๋Šฅ or ์•„๋‹Œ์ง€ ํ‘œํ˜„ํ•˜๋Š” Invalid bit 

-> ์ผ๋‹จ ๋‹ค ์•ˆ ์˜ฌ๋ฆผ, ์‹œ์ž‘ ์‹œ ๋ชจ๋‘ invalid bit 

- ๊ทธ ํŽ˜์ด์ง€๊ฐ€ ์ฐธ์กฐ๋˜๋Š” ์‹œ์ ์— valid๋กœ ์˜ฌ๋ฆผ -> demand paging

 

* ์ƒˆ๋กญ๊ฒŒ ์ •์˜๋œ ์˜๋ฏธ

1. valid bit (v) – ์ฐธ์กฐํ•  ์ˆ˜ ์žˆ๋Š” ์˜์—ญ, ์ง€๊ธˆ ํ˜„์žฌ physical memory์— ์žˆ๋‹ค (in memory ์˜๋ฏธ)

2. invalid bit (i) – ๋‚ด๊ฐ€ ์ฐธ์กฐํ•  ์ˆ˜ ์—†๋Š” ์˜์—ญ (protection fault) or 
              
์žˆ๊ธด ์žˆ๋Š”๋ฐ, ์ง€๊ธˆ ํ˜„์žฌ ๋ฉ”๋ชจ๋ฆฌ์— ์—†๋‹ค! (secondary storage์—, ๋”ฐ๋ผ์„œ Page fault)

+ ์ฒ˜์Œ์—๋Š” ๋ชจ๋‘ invalid๋กœ ์„ค์ •๋˜์–ด ์žˆ๋‹ค. 

 

- CPU๊ฐ€ ๋ฉ”๋ชจ๋ฆฌ ์ฐธ์กฐ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๋Š” ์‹œ์ ์— (exec time) 

- virtual (logical) address <-> physical address mapping by MMU 

1. TLB hit (99%)  TLB miss -> 2. Page table -> ๋”์ด์ƒ CPU(MMU)๊ฐ€ ์ง„ํ–‰ํ•  ์ˆ˜ ์—†์Œ -> fault

-> falut ๊ฑธ๋ ธ์œผ๋‹ˆ, OS๊ฐ€ ์ฒ˜๋ฆฌ -> secondary storage (backing store) – I/O 

-> free frame์— ๊ฐ€์ ธ์˜ด -> ํ•ด๋‹น frame number๋ฅผ ๊ธฐ์ž…ํ•˜๊ณ , invalid๋ฅผ valid๋กœ ๋ณ€๊ฒฝ 

-> ๋ช…๋ น์–ด๋ฅผ restart ์‹œํ‚ค๋ฉด main memory access ๊ฐ€๋Šฅ! 

 

+ protection fault – ์ฐธ์กฐํ•  ์ˆ˜ ์—†๋Š” ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ์„ ์ฐธ์กฐ – program bug

- page fault – main memory๋ฅผ ์ถฉ๋ถ„ํžˆ ๋‹ฌ์•˜์–ด์•ผ ํ•จ 

 

- Copy on write: fork ์‹œ memory management // Unix

- ํ”„๋กœ์„ธ์Šค fork ์‹œ ๋ฐ”๋กœ copy ๋˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ, writeํ•˜๋Š” ์‹œ์ ์— ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์ด ๋ถ„๋ฆฌ๋˜๋Š” ๊ฒƒ

 

* free frame์ด ์—†๋‹ค๋ฉด? -> main memory์˜ ๋ชจ๋“  frame์ด ๋‹ค ์‚ฌ์šฉ ์ค‘์ด๋‹ค. (์—ฌ๋Ÿฌ process ์‹คํ–‰ ์ค‘์ด๋ผ)

- ์–ด๋–ค page๊ฐ€ ๋ฉ”์ธ ๋ฉ”๋ชจ๋ฆฌ์— ์˜ฌ๋ผ์˜ค๋ฉด์„œ, ๋‹ค๋ฅธ Page๋Š” backing store๋กœ ๋‚ด๋ ค๊ฐ (i ์ค‘ ํ•˜๋‚˜๋ฅผ ๋‚ด๋ ค์„œ ์ฒ˜๋ฆฌ)

-> page replacement (ํŽ˜์ด์ง€ ๊ต์ฒด)

: ์–ด๋–ค page๋ฅผ ๋‚ด๋ ค ๋ณด๋‚ผ ๊ฒƒ? (page replacement algorithm) – ์˜ค๋ž˜ ์‚ฌ์šฉ๋˜์ง€ ์•Š์€ ๊ฒƒ์„ ๋‚ด๋ฆฌ์ž. 

-> ์•ž์œผ๋กœ๋„ ์‚ฌ์šฉ๋˜์ง€ ์•Š์„ ํ™•๋ฅ ์ด ๋†’๊ธฐ ๋•Œ๋ฌธ์— (locality) -> victim(ํฌ์ƒ์–‘)์„ ์ •ํ•ด swapํ•œ๋‹ค. 

 

* page replacement algorithm – ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ๋ชฉํ‘œ – Lowest page fault rate

- page faults vs Number of frames (main memory free frame ์ˆ˜์™€ page fault๋Š” ๋ฐ˜๋น„๋ก€ ๊ด€๊ณ„)

-> free frame ์ˆ˜๊ฐ€ ๋งŽ์„์ˆ˜๋ก, page faults๊ฐ€ ๋œ ๋ฐœ์ƒํ•œ๋‹ค. 

 

1. FIFO – ๊ฐ€์žฅ fair, but locality์— ๋Œ€ํ•œ ์ดํ•ด๊ฐ€ ์—†์Œ. ์„ฑ๋Šฅ์ด ๋‚ฎ๋‹ค – Bradly’s anomaly 

Process๊ฐ€ 3๊ฐœ์˜ frame ํ• ๋‹น – 9 fault, 4๊ฐœ frame ํ• ๋‹น ๋ฐ›์œผ๋ฉด 10 fault๊ฐ€ ๋ฐœ์ƒ

-> locality๋ฅผ ์ „ํ˜€ ๊ณ ๋ คํ•˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์— 

 

+ memory 4GB / frame 4KB -> frame์ด 1M๊ฐœ (2^20, ๋ฐฑ๋งŒ) / process 100๊ฐœ -> 1๊ฐœ ๋‹น 10,000 frame

 

2. Optimal algorithm – ๋‚˜๋ณด๋‹ค ๋” ์ข‹์€ ์„ฑ๋Šฅ์„ ๊ฐ€์ง„ ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ์—†๋‹ค

- replace page that will not be used for longest period of time (๊ฐ€์žฅ ์˜ค๋žซ๋™์•ˆ ์•ˆ ์“ฐ์ผ ๊ฒƒ์„ ๊ต์ฒด)

- ์ฒ˜์Œ ์• ๋“ค์€ ๋ฌด์กฐ๊ฑด Fault๊ฐ€ ๋‚จ -> demand paging ๋•Œ๋ฌธ

- ๊ณง reference ๋  ์• ๋“ค์€ ๋‚ด๋ฆฌ์ง€ ์•Š์Œ 

- ํ•˜์ง€๋งŒ ์ˆœ์„œ๋ฅผ ๋ฏธ๋ฆฌ ์•Œ ์ˆ˜ ์—†๋‹ค -> ๊ณผ๊ฑฐ๋ฅผ ํ†ตํ•ด ๋ฏธ๋ž˜๋ฅผ ์˜ˆ์ธกํ•ด์•ผ ํ•จ  ์—ญ์‹œ๋‚˜ locality

 

3. LRU – Least Recently Used ์•Œ๊ณ ๋ฆฌ์ฆ˜ – optimal์— ๊ทผ์ ‘ํ•œ ์„ฑ๋Šฅ

- ๊ฐ€์žฅ ์˜ค๋žซ๋™์•ˆ ์‚ฌ์šฉ๋˜์ง€ ์•Š์€ page๋ฅผ ๊ต์ฒดํ•œ๋‹ค. (๊ณผ๊ฑฐ๋กœ๋ถ€ํ„ฐ ๋ฏธ๋ž˜๋ฅผ ์ถ”์ธกํ•œ๋‹ค)

-> page๊ฐ€ ์–ธ์ œ ์ฐธ์กฐ๋˜์—ˆ๋Š”์ง€, ๊ทธ ์ •๋ณด๋ฅผ ๊ฐ–๊ณ  ์žˆ์–ด์•ผ ํ•จ. 2๊ฐ€์ง€ ๋ฐฉ๋ฒ• ์ œ์‹œ 

 

1) timestamp implementation – page ๋ณ„ time stamp๋ฅผ ๊ธฐ๋กํ•˜๊ฒ ๋‹ค. 

2) Stack implementation – ๋ฉ”๋ชจ๋ฆฌ ์ฐธ์กฐ๋  ๋•Œ ๋งˆ๋‹ค ์Šคํƒ ๊ตฌ์กฐ ๋ณ€๊ฒฝ  ์˜ค๋ฒ„ํ—ค๋“œ ๋„ˆ๋ฌด ์ปค์„œ ๋ถˆ๊ฐ€๋Šฅ 

+ ํƒ€์ž„ ์Šคํƒฌํ”„๋„ ์˜ค๋ฒ„ํ—ค๋“œ ๋ถ€๋‹ด์Šค๋Ÿฌ์›€ -> ์ž‘์€ ๋น„ํŠธ๋กœ ์ถ”์ •(approximation)ํ•˜์ž -> 1 bit๋กœ ํ™• ์ค„์ž„

 

* Reference bit -> 1 or 0 – ์–ด๋–ค page๊ฐ€ ์ฐธ์กฐ๋  ๋•Œ, reference bit๋ฅผ 1๋กœ ์„ธํŒ…ํ•œ๋‹ค. 

- ์ฃผ๊ธฐ์ ์œผ๋กœ reference๋ฅผ 0์œผ๋กœ ๋งŒ๋“ฆ -> replace๊ฐ€ ์ด๋ฃจ์–ด์งˆ ๋•Œ, 1๊ณผ 0 ์ค‘ 0์„ ๋‚ด๋ฆฌ๊ฒ ๋‹ค. 

- 0์ด ์—ฌ๋Ÿฌ ๊ฐœ๋ผ๋ฉด? ๋žœ๋ค์œผ๋กœ ๋‚ด๋ฆผ 

 

+ ์‹ค์ œ CPU๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ• – Second Chance (LRU lock) – ํ•œ ๋ฒˆ ๋” ๊ธฐํšŒ๋ฅผ ์ค€๋‹ค!

- circular queue of pages๋กœ ํ•œ ๋ฒˆ ๋ด์ค€๋‹ค

 

4. NRU - Not Recently Used  ํ˜„์žฌ CPU๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹

- R(reference), M(modified) bit๋ฅผ ํ™œ์šฉํ•œ๋‹ค. 

1. Class 0 – R = 0, M = 0, ์ตœ๊ทผ์— ์ฐธ์กฐ๋„, ๋ณ€๊ฒฝ๋„ X -> ๊ฐ€์žฅ ์šฐ์„ ์ ์œผ๋กœ ์ซ“์•„๋ƒ„

2. Class 1 – R = 0, M = 1, ์ตœ๊ทผ์— ์ฐธ์กฐX, ๋ณ€๊ฒฝO -> ๊ทธ ๋‹ค์Œ์œผ๋กœ ์ซ“์•„๋ƒ„

3. Class 2 – R = 1, M = 0, ์–˜๊ฐ€ ๊ทธ๋‚˜๋งˆ ๋” ์ž์ฃผ ์ฐธ์กฐ๋  ๊ฐ€๋Šฅ์„ฑ ์žˆ๋‹ค. 

4. Class 3 – R = 1, M = 1, ๊ฐ€์žฅ ๋‚ฎ์€ ์ซ“๊น€ ์ˆœ์œ„ 

 

+ PTEs (page table entries) -> ์—ฌ๊ธฐ์„œ ๋‚˜์˜จ R, M bit! 

- Page table์—์„œ ์ง€์›ํ•œ๋‹ค == CPU์—์„œ ์ง€์›ํ•œ๋‹ค (ํ•˜๋“œ์›จ์–ด์ ์œผ๋กœ)

 

5. LFU – Least Frequently Used – ์•„๊นŒ๋Š” ์‹œ๊ฐ„, ์ด๊ฑด ํšŸ์ˆ˜ count ๊ธฐ์ค€

- Counting based page replacement – ์ด๊ฒƒ๋„ ์˜ค๋ฒ„ํ—ค๋“œ ๋•Œ๋ฌธ์— ํ•œ ๋น„ํŠธ๋กœ ์ค„์ด๋ฉด (approximation), ๊ฒฐ๊ตญ LRU๋‚˜ LFU๋‚˜ ๋˜‘๊ฐ™์ด ๋จ  ์„ฑ๋Šฅ์ด ๋‘˜ ๋‹ค optimal

 

* Allocation of frames – process์—๊ฒŒ free ํ”„๋ ˆ์ž„์„ ์–ผ๋งˆ๋‚˜ ํ• ๋‹นํ•  ๊ฒƒ์ธ๊ฐ€?

- Proportional allocation – process์˜ ํฌ๊ธฐ์— ๋น„๋ก€ํ•˜์—ฌ ํ• ๋‹น 

- Priority-based allocation 

 

+ Page replacement 

- global replacement

- local replacement – ํ˜„์žฌ OS๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•: ํ•ด๋‹น process ๋‚ด์—์„œ ๊ต์ฒด

 

- Page fault frequency scheme (free frame ์ˆ˜ ๋Œ€๋น„, page fault ๋น„์œจ)

- Page fault๊ฐ€ ์ž์ฃผ ๋ฐœ์ƒํ•˜๋Š” process -> ์–˜๋Š” frame์ด ๋ถ€์กฑํ•˜๊ตฌ๋‚˜  ๋” ํ• ๋‹นํ•ด ์คŒ

- Page fault ๋น„์œจ์ด ๋งค์šฐ ๋‚ฎ์€ process -> ์–˜๋Š” ์—ฌ์œ ๊ฐ€ ์žˆ๊ตฌ๋‚˜  ๋‹ค๋ฅธ ์• ์—๊ฒŒ ์ค„ ์ˆ˜ ์žˆ์Œ

 

* Thrashing – process is busy swapping pages in and out 

- process์˜ ์ˆ˜๊ฐ€ ๋Š˜์–ด๋‚˜๋‹ค ๋ณด๋ฉด, CPU utilization์ด ํ™• ์ค„์–ด๋“œ๋Š” ์ง€์  -> thrashing

- CPU๊ฐ€ Disk IO๋งŒ ํ•˜๋Š” ๊ฒƒ // locality (์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ๋ฉ”๋ชจ๋ฆฌ)์˜ ํ•ฉ์ด ์ „์ฒด ๋ฉ”์ธ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์ด์ฆˆ๋ณด๋‹ค ํด ๋•Œ 

 

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• 1. Main memory๋ฅผ ๋” ๋Š˜๋ฆฐ๋‹ค. 2. ์‹คํ–‰ ์ค‘์ธ Process์˜ ์ˆ˜๋ฅผ ์ค„์ธ๋‹ค. 

- ๋ฉ”๋ชจ๋ฆฌ์— ๋น„ํ•ด, ํ”„๋กœ์„ธ์Šค๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ๋” ๋งŽ์€ ๊ฒƒ 

 

- Working-Set model

- working set size == locality์˜ ํฌ๊ธฐ 

- ํ•ด๋‹น process๊ฐ€ ์ตœ๊ทผ ์ฐธ์กฐํ•œ page๋“ค์˜ ์ง‘ํ•ฉ // WSS๊ฐ€ ์ž‘์„์ˆ˜๋ก locality๊ฐ€ ์šฐ์ˆ˜ํ•œ process

- ๋ชจ๋“  process๋“ค์˜ working set size์˜ ํ•ฉ D > M – ๋ฉ”์ธ๋ฉ”๋ชจ๋ฆฌ ํฌ๊ธฐ -> thrashing ๋ฐœ์ƒ

 

- Prepaging – ์ธ๊ทผ์˜ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๋ฏธ๋ฆฌ Disk์—์„œ ์ฝ์–ด์˜ค๋Š” ๊ฒƒ 

-> Spatial locality

 

- Page size์— ๋Œ€ํ•œ ํŠน์„ฑ๋“ค

- internal fragmentation -> ์ž‘์„์ˆ˜๋ก ์ข‹๋‹ค 

- Page table size – ํฐ ๊ฒŒ ์ข‹๋‹ค. 

- I/O Overhead – ํฐ ๊ฒŒ ์ข‹๋‹ค. 

- Locality – ํฐ ๊ฒŒ ์ข‹๋‹ค. 

 

* TLB reach – TLB๊ฐ€ ์ปค๋ฒ„ํ•˜๋Š” ๋ฉ”๋ชจ๋ฆฌ ์˜์—ญ 

–> ์ด ์ž…์žฅ์—์„œ๋„ page size๊ฐ€ ํฐ ๊ฒƒ์ด ์ข‹๋‹ค. 

- TLB Reach = (TLB size) * (Page size)

 

+ index ์—ฐ์‚ฐ, j -> i : A[i][j] -> 1024*1024 page faults 

- i -> j : A[i][j] -> 1024 page faults

+ 32bit integer 1024๊ฐœ -> 4KB -> page size

 

+ DMA (direct memory access) – I/O๊ฐ€ ์ง์ ‘ disk์— ์”€ 

- main memory์— ์ง์ ‘ ์ ‘๊ทผ (CPU register์— ๋‹ด์„ ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์—) 

- ์ด๋•Œ virtual memory management ๊ณ ๋ คX, lock์„ ๊ฑธ๊ณ  I/O ์žฅ์น˜๋งŒ ์‚ฌ์šฉํ•œ๋‹ค. 

- virtual memory์˜ free frame ์˜์—ญ์— ๋“ค์–ด๊ฐ€์„œ๋Š” ์•ˆ๋จ

 

 

 

 

 

11. Mass-Storage Structure

- I/O ์žฅ์น˜ ๊ด€๋ฆฌ, secondary storage, mass storage

- HDD – hard disk drive – ๊ธฐ๊ณ„์  

- SDD – Solid State disk – ์ „๊ธฐ์ 

- RAM disk – ์ „์› ๊ป๋‹ค๊ฐ€ ์ผœ๋ฉด, ๋‹ค ๋‚ ๋ผ๊ฐ€๋Š” ๋ฉ”๋ชจ๋ฆฌ – iptime 

- Magnetic tape – data ๋ฐฑ์—… ์šฉ๋„๋กœ ์‚ฌ์šฉ

 

- Disk attachment 

1) Host attached – ๊ฐœ์ธ PC

2) Network attached – ์—ฐ๊ตฌ์‹ค NAS

 

* Network Attached Storage – NAS

- IP ๋„คํŠธ์›Œํฌ๋ฅผ ํ†ตํ•ด ์ ‘๊ทผ / file level access / ์—ฌ๋Ÿฌ ์‚ฌ์šฉ์ž๋“ค์ด ๊ณต์œ ํ•˜๋Š” storage

 

* Storage Area Network – SAN 

- block level access / Use storage protocols SCSI or Fibre channel -> Non-IP networks

- ๋””์Šคํฌ๋“ค์ด ๋„คํŠธ์›Œํฌ๋กœ ์—ฐ๊ฒฐ๋จ ex) ๋ฐ์ดํ„ฐ ์„ผํ„ฐ ์„œ๋ฒ„ 

- SAN์˜ ํŒŒ์ผ ๋‹จ์œ„์™€ ๋‹ฌ๋ฆฌ, ํ•˜๋‚˜์˜ ํฐ ๋””์Šคํฌ, ๋ธ”๋ก์œผ๋กœ ๋ณด๋Š” ๊ฒƒ 

 

- HDD structure 

- ํŠน์ • rpm์œผ๋กœ ๊ณ„์† ๋„๋Š” ์ถ• spindle / ๊ธฐ๋‘ฅ cylinder / platter ํŒ / platter์˜ ํ•œ ๋ฉด surface / surface ์œ„์˜ ๋™์‹ฌ์› track / track์˜ ์ผ๋ถ€๋ถ„ sector / arm / head 

- ํ•˜๋“œ์›จ์–ด์ ์œผ๋กœ cylinder, surface, track, sector ๋„˜๋ฒ„ ๋Œ€์‹ , logical block ๋‹จ์œ„๋กœ ์ฝ์Œ 

 

* 3๋‹จ๊ณ„๋กœ ์ด๋ฃจ์–ด์ง€๋Š” disk performance 

1) Seek  ๋งค์šฐ ๋Š๋ฆผ, ๋””์Šคํฌ arm์„ ์›ํ•˜๋Š” ์‹ค๋ฆฐ๋”๋กœ ์˜ฎ๊ธฐ๋Š” ๊ฒƒ, ๊ธฐ๊ณ„์  

2) Rotation – ์›ํ•˜๋Š” sector๊ฐ€ head ๋ฐ‘์œผ๋กœ ์˜ค๋„๋ก ํšŒ์ „ํ•˜๋Š” ๊ฒƒ, ๊ธฐ๊ณ„์ 

3) Transfer – surface์—์„œ disk controller๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ๋Š” ๊ฒƒ, ์ „๊ธฐ์  ์‹ ํ˜ธ๋กœ ์ฝ์–ด ๋น ๋ฅด๋‹ค. 

-> Disk scheduling -> minimize seek time // seek time == seek distance 

 

1. FCFS – ๊ฐ€์žฅ fair – ํ์— ๋“ค์–ด์˜จ ์ˆœ์„œ๋Œ€๋กœ ์ฝ๋Š”๋‹ค. Seek time์„ ๊ณ ๋ คํ•˜์ง€ ์•Š์Œ

+ ํ์˜ ์ˆซ์ž – Cylinder, track number๋ฅผ ์˜๋ฏธํ•œ๋‹ค. 

 

2. SSTF – Shortest Seek Time First 

- ํ˜„์žฌ head ์œ„์น˜์—์„œ ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ๊ฒƒ์„ ์„ ํƒ – seek time ์ตœ์†Œํ™”

- ์ผ์ข…์˜ SJF(shortest job first) – ์ด๊ฑด ๋ฏธ๋ฆฌ ์•Œ ์ˆ˜ ์—†์—ˆ์ง€๋งŒ, ๋””์Šคํฌ๋Š” ์ˆœ์„œ๋ฅผ ๋ฏธ๋ฆฌ ์•Œ ์ˆ˜ ์žˆ์Œ 

- starvation์„ ์œ ๋ฐœํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

3. SCAN – ํ—ค๋“œ๋ฅผ ํ•œ์ชฝ์œผ๋กœ ์ญ‰ ์Šค์บ”ํ•˜์—ฌ ์ฒ˜๋ฆฌ 

- ์™ผ์ชฝ์œผ๋กœ ์ญ‰ -> ์™ผ์ชฝ ๋์— ๋„๋‹ฌํ•˜๋ฉด ๋ฐฉํ–ฅ ์ „ํ™˜ -> ์˜ค๋ฅธ์ชฝ์œผ๋กœ ์ญ‰ 

 

* ๊ฒฐ๋ก  

- ์ผ๋ฐ˜์ ์œผ๋กœ๋Š” – SSTF ์‚ฌ์šฉ 

- disk ์š”์ฒญ์ด ๋งŽ๋‹ค๋ฉด –> SCAN – ๋น„๋””์˜ค ์‹œ์ฒญ ๊ฐ™์€ ๊ฒฝ์šฐ // heavy load

 

+ C-SCAN: ํ•œ๋ฒˆ์— ์ญ‰ ์˜ค๋ฅธ์ชฝ ๋๊นŒ์ง€ ๊ฐ„ ๋‹ค์Œ, ์™ผ์ชฝ ๋์œผ๋กœ ํ—ค๋“œ๋ฅผ ์˜ฎ๊น€  ์“ธ๋ชจ์—†๋Š” ์˜ค๋ฒ„ํ—ค๋“œ

+ C-LOOK: ๋’ค์— ๋” ์š”์ฒญ์ด ์—†๋‹ค๋ฉด, ๋ฐ˜๋Œ€์ชฝ ๋์œผ๋กœ ๊ฐ€๋ผ -> C-SCAN + a 

 

- Disk controller (I/O controller)

- BUS์™€ ์—ฐ๊ฒฐ๋˜์–ด, ์‹ค์ œ IO ์žฅ์น˜๋“ค์„ ์ œ์–ดํ•˜๋Š” ์ž‘์€ ์ปดํ“จํ„ฐ

- ์˜ˆ์ „์—๋Š” OS๊ฐ€ ํ•˜๋˜ ์ผ๋“ค์„ ๋˜‘๋˜‘ํ•ด์ง„ Disk controller๊ฐ€ ํ•˜๋Š” ๊ฒƒ

 

* Swap Space management 

- Swap space – backing store – virtual memory๊ฐ€ ๋””์Šคํฌ์˜ ๊ณต๊ฐ„์„ ๋ฉ”์ธ ๋ฉ”๋ชจ๋ฆฌ์˜ ์—ฐ์žฅ์„ ์—์„œ ์‚ฌ์šฉํ•จ 

- ์œˆ๋„์šฐ์™€ ๋‹ฌ๋ฆฌ ๋ฆฌ๋ˆ…์Šค๋Š” ๋ณ„๋„์˜ partition์„ ์žก์Œ / main memory์˜ 2๋ฐฐ๋ฅผ swap space๋กœ ์žก์Œ 

 

* RAID  Redundant Array of Inexpensive Disks = ์ €๋ ดํ•œ ๋””์Šคํฌ๋ฅผ ์ค‘๋ณตํ•˜์—ฌ ๋งค์šฐ ๋งŽ์ด ๋ฐฐ์น˜ 

1. reliability ์ค‘๋ณตํ•˜์—ฌ ์ €์žฅ -> ์‹ ๋ขฐ๋„๊ฐ€ ์˜ฌ๋ผ๊ฐ„๋‹ค. (mirroring, shadowing – ๋˜‘๊ฐ™์ด ์ €์žฅ, or Parity, error correcting codes – ์†์ƒ๋˜์–ด๋„ ๋ณต๊ตฌํ•  ์ˆ˜ ์žˆ๋„๋ก) 

2. parallelism์„ ํ†ตํ•ด ์„ฑ๋Šฅ ํ–ฅ์ƒ (data striping = bit level vs block level)

 

1) bit level striping – parallelism – ํ•˜๋‚˜์˜ ์š”์ฒญ์„ ๋ชจ๋“  ๋””์Šคํฌ๊ฐ€ ์ˆ˜ํ–‰ / ๋””์Šคํฌ๋“ค์„ ๊ด€ํ†ตํ•˜๋Š” ๊ฐ€๋กœ๋กœ ๊ธธ๊ฒŒ 

2) block level striping – concurrency – 4๊ฐœ ์˜์—ญ์„ ๋™์‹œ์— ์ฝ๊ธฐ ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ์žฅ์  / ๊ฐ ๋””์Šคํฌ ๋ณ„๋กœ ๋‹ค๋ฅธ ๋ธ”๋ก 

-> HDD๋Š” ํ•œ ๋ฒˆ์— ๋งŽ์ด ์ฝ์–ด์•ผ ์„ฑ๋Šฅ์ด ์˜ฌ๋ผ๊ฐ -> ๋”ฐ๋ผ์„œ block level์ด ๋” ์šฐ์ˆ˜ 

 

1. RAID 0

- ์˜ค์ง concurrency๋งŒ / data๊ฐ€ ๋‚ ๋ผ๊ฐ€๋„ ์ƒ๊ด€X, ์„ฑ๋Šฅ์ด ์ค‘์š”ํ•˜๋‹ค / OS๊ฐ€ ๋™์‹œ์— 4๊ฐœ์˜ request๋ฅผ concurrentํ•˜๊ฒŒ ์ฝ๋Š” ๊ฒƒ 

- non-redundant striping – no reliability (์‹ ๋ขฐ๋„๋Š” ๋ฌด๊ด€)

 

2. RAID 1 

- ์„ฑ๋Šฅ์€ ์ค‘์š”X, ์‹ ๋ขฐ๋„๋งŒ ์ค‘์š”ํ•˜๋‹ค. Mirrored disks – ๋˜‘๊ฐ™์ด ๋ณต์‚ฌ๋ณธ๋งŒ ํ•˜๋‚˜ ๋” ๋งŒ๋“  ๊ฒƒ 

 

3. RAID 2

- bit level (์‚ฌ์‹ค ์•ˆ ์“ฐ์ž„) / error-correcting codes (ECC) – 3๊ฐœ๋กœ 4๊ฐœ ๋ณต๊ตฌ ๊ฐ€๋Šฅ 
/ 4
๊ฐœ ์ค‘ 3๊ฐœ ๊ณ ์žฅ๊นŒ์ง€ ๋ณต๊ตฌ ๊ฐ€๋Šฅ 

 

4. RAID 3

- bit level / Parity – 4๊ฐœ ์ค‘ ํ•˜๋‚˜๊ฐ€ ๊ณ ์žฅ๋‚˜๋ฉด P๋ฅผ ํ†ตํ•ด ๋ณต๊ตฌ ๊ฐ€๋Šฅ, 4๊ฐœ์ค‘ 2๊ฐœ ์ด์ƒ ๊ณ ์žฅ ์‹œ ๋ณต๊ตฌ X

 

5. RAID 4 

- block level striping / Parity๊ฐ€ ๋™์ผํ•œ ์ค„์— ์žˆ๋‹ค 

- write ๋ฐ update ์‹œ P๋„ ํ•จ๊ป˜ ๋ฐ”๋€Œ์–ด์•ผ ํ•œ๋‹ค -> read ์‹œ์—๋Š” ๋ฌธ์ œ X 

-> P๊ฐ€ ์žˆ๋Š” ์ค„๋งŒ ๋„ˆ๋ฌด ๋ฐ”์จ 

 

6. RAID 5 * ๊ฐ€์žฅ ๋งŽ์ด ์“ฐ์ด๋Š” configuration 

- block level / Parity๋„ striping (distributed parity) 

- ์„œ๋กœ ๋‹ค๋ฅธ ๋””์Šคํฌ๋“ค๋กœ ๋ฟŒ๋ฆผ / ๊ณ ์žฅ ์ž˜ ์•ˆ ๋‚œ๋‹ค๋ฉด RAID 5๋กœ ์ถฉ๋ถ„ํ•˜๋‹ค. 

 

7. RAID 6 

- 2๊ฐœ๊ฐ€ ๊ณ ์žฅ๋‚˜๋”๋ผ๋„ ๋ณต๊ตฌํ•˜๊ณ  ์‹ถ๋‹ค -> RAID 5์—์„œ P๋ฅผ 2๋กœ ๋Š˜๋ฆฐ ๊ฒƒ

 

* ๋ˆ์ด ๋” ๋งŽ๋‹ค๋ฉด mirroring 

8. RAID 0 + 1

-RAID 0 – ๋ธ”๋Ÿญ ๋ ˆ๋ฒจ๋กœ -> RAID 1 – ๊ทธ ๋’ค, ํ†ต์œผ๋กœ ๋ณต์‚ฌ 

- ์ด๋•Œ, RAID ๋ฉ์–ด๋ฆฌ ์ค‘ ํ•˜๋‚˜๋งŒ ๊ณ ์žฅ๋‚˜๋„ ๋ฉ์–ด๋ฆฌ ์ฑ„๋กœ ๋‚ ๋ผ๊ฐ 

 

9. RAID 10 (RAID 1 + 0) 

- RAID 1 -> ๋จผ์ € ๋ณต์‚ฌํ•˜๊ณ  -> ์ดํ›„ RAID 0 – ๋ธ”๋Ÿญ์œผ๋กœ ์ฒ˜๋ฆฌ

- ์ฆ‰ ์ค„ ๋ณ„๋กœ ๋ณต์‚ฌ๋œ ํ˜•ํƒœ -> ๊ณ ์žฅ๋œ ์ค„๋งŒ ๋ณต์‚ฌ๋ณธ์œผ๋กœ ๋Œ€์ฒด๋˜๊ณ , ๋‚˜๋จธ์ง€๋Š” ๋ชจ๋‘ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•จ

- RAID 0+1๋ณด๋‹ค ์„ฑ๋Šฅ์ด ๋” ์šฐ์ˆ˜ํ•˜๋‹ค. 

 

 

 

 

 

12. I/O systems

I/O operation 

 Direct I/O vs Memory Mapped I/O

- Communicate with registers in I/O controller – MCU (์ž‘์€ ์ปดํ“จํ„ฐ) 

- IR (instruction register) & DR (data register)

 

I/O method

- Programmed I/O  ์ž‘์€ ๋‹จ์œ„๋ผ๋ฉด CPU์—๊ฒŒ ์ „๋‹ฌ

- DMA (Direct Memory Access)  ํฐ ๋‹จ์œ„, ๋””์Šคํฌ์— ์ง์ ‘ ์”€

- Interrupt – ํ•˜๋“œ์›จ์–ด๊ฐ€ ์ผ์„ ๋๋‚ด๊ฑฐ๋‚˜, I/O event ๋ฐœ์ƒ ์‹œ CPU์—๊ฒŒ ์•Œ๋ฆผ

 

- Direct I/O – memory์™€ I/O ๋ฒ„์Šค๊ฐ€ ๋ณ„๋„๋กœ ์กด์žฌ separate address – intel CPU

- Memory Mapped I/O – integrated address – ๋” ๊ฐ„๋‹จํ•œ ๊ตฌ์กฐ – ARM CPU

 

* I/O Device controller – ์ž‘์€ ์ปดํ“จํ„ฐ๋ฅผ ์˜๋ฏธํ•œ๋‹ค. 

- Device controller (== Host adapter) ex) Disk controller, keyboard controller -> ๋” ๋˜‘๋˜‘ํ•ด ์ง 

 

+ I/O Performance 

- CPU Cache๊ฐ€ ๊ฐ€์žฅ ์„ฑ๋Šฅ์ด ์ข‹๋‹ค / DRAM / SSD / HDD (๋’ค๋กœ ๊ฐˆ์ˆ˜๋ก latency ์ฆ๊ฐ€)

 

- Kernel I/O ๊ตฌ์กฐ 

- Device์™€ 1:1 mapping ๋˜๋Š” device controller (I/O๋ฅผ ์ง์ ‘ ์ปจํŠธ๋กค) // hardware 

- Device Driver –> device๋ฅผ ๊ตฌ๋™์‹œํ‚ค๋Š” software, ๊ทธ ์œ„์˜ kernel // software

 

- Device – functionality Progression 

- ๊ฐ€์žฅ software (flexibility ๋†’์Œ) application code / kernel code / device-driver code // device controller code (hardware, firm ware) / device code (์ฐ hardware) 

- hardware์— ๊ฐ€๊นŒ์šธ์ˆ˜๋ก, ๊ฐœ๋ฐœ ๋น„์šฉ ์ฆ๊ฐ€, ํšจ์œจ์„ฑ๋„ ์ฆ๊ฐ€, ์ถ”์ƒํ™” ๋‹จ๊ณ„๋„ ์ฆ๊ฐ€, ์ƒ์„ฑํ•˜๋Š”๋ฐ ์‹œ๊ฐ„๋„ ์ฆ๊ฐ€

-> (time, efficiency, development cost, abstraction vs flexibility) 

 

- interrupt handler – interrupt๋ฅผ ์ฒ˜๋ฆฌ 

: ์งง์€, ์ค‘์š”ํ•œ interrupt๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” critical actions / non-critical action์œผ๋กœ ๋‚˜๋‰˜๊ณ  / ์ดํ›„ OS๊ฐ€ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ถ€๋ถ„์œผ๋กœ ๋‚˜๋‰จ

 

- device drivers – device specific code to control each I/O device interacting with device independent I/O software and interrupt handler – ์—ฌํ•˜ํŠผ ์ด๊ฑด software๋‹ค! 

 

+ Unix / linux์—์„œ I/O software ๊ฐœ๋ฐœ ์‹œ, special files ํ˜•ํƒœ๋กœ ๊ฐœ๋ฐœํ•œ๋‹ค. 

 

* Buffering – CPU๋Š” ๋น ๋ฅด์ง€๋งŒ, I/O๋Š” ๋งค์šฐ ๋Š๋ฆผ -> I/O data๊ฐ€ buffer์— ์ €์žฅ๋˜๊ณ , ์ด๋ฅผ CPU๊ฐ€ ๊บผ๋‚ด์„œ ์‚ฌ์šฉ

- ์„ฑ๋Šฅ ์ธก๋ฉด์—์„œ๋Š” application์ด ์ง์ ‘ ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์ง€๋งŒ, ์ผ๋ฐ˜์ ์œผ๋กœ ์ปค๋„์ด I/O ๋””๋ฐ”์ด์Šค๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค. 

(์ปค๋„์„ ๊ฑฐ์ณ์„œ user mode, application์—๊ฒŒ ์ „๋‹ฌ๋˜๋Š” ๊ฒƒ) 

 

* Spooling – ํ”„๋ฆฐํ„ฐ ์˜ˆ์‹œ

- ์ผ๋ฐ˜์ ์œผ๋กœ ๋ฒ„ํผ๋ง์„ ์‚ฌ์šฉํ•˜๋‚˜, ํ”„๋ฆฐํ„ฐ๋Š” ๋งค์šฐ ๋Š๋ฆผ, ๋ฐ์ดํ„ฐ ๋‚ด์šฉ๋„ ๋งŽ๋‹ค. ๋”ฐ๋ผ์„œ application์—์„œ ํ”„๋ฆฐํ„ฐ๋กœ ๋ณด๋‚ผ ํŒŒ์ผ์„ ๋ฏธ๋ฆฌ ๋งŒ๋“ค์–ด, ์ปค๋„์— ์ „๋‹ฌํ•˜๊ณ , ์ด๋ฅผ ํ”„๋ฆฐํ„ฐ๋กœ ๋‚ด๋ณด๋‚ด๋Š” ๋ฐฉ์‹ -> Spooling์ด๋ผ๊ณ  ํ•œ๋‹ค.

 

 

 

 

 

13. File System Interface 

- ์‚ฌ์šฉ์ž ์ž…์žฅ์—์„œ์˜ ํŒŒ์ผ ์‹œ์Šคํ…œ

- long term information storage – ์ „์›์ด ๊บผ์ง€๋”๋ผ๋„ ์˜ค๋ž˜ ์œ ์ง€๋˜์–ด์•ผ ํ•œ๋‹ค. 

- ํŒŒ์ผ๋“ค์„ logically ์กฐ์งํ•œ๋‹ค – directory / Sharing๊ณผ protection ๊ธฐ๋Šฅ๋„ ์žˆ์–ด์•ผ ํ•จ 

 

* Text file vs binary file 

- Text file – ์•„์Šคํ‚ค ์ฝ”๋“œ, .txt, .cpp -> ํ…์ŠคํŠธ๋‚˜ ์†Œ์Šค ์ฝ”๋“œ ํŒŒ์ผ๋“ค์ฒ˜๋Ÿผ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ”๋“œํ™” ํ•œ ๊ฒƒ

- binary file – ๋ฐ์ดํ„ฐ ๊ทธ ์ž์ฒด๋กœ ์˜๋ฏธ๊ฐ€ ์žˆ๋Š” ํŒŒ์ผ ex) ์‹คํ–‰ ํŒŒ์ผ, .hwp ํ•œ๊ธ€ ํŒŒ์ผ (๊ทธ๋ฆผ์ด ์‚ฝ์ž…๋œ ๊ฒฝ์šฐ). PPT, word ํŒŒ์ผ ๋“ฑ๋“ฑ ๋Œ€๋ถ€๋ถ„ binary ํŒŒ์ผ 

 

- file operation system call 

Ex) int open, int close, size_t read, size_t write -> ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ file operation system call // OS์—๊ฒŒ ์š”์ฒญ

 

- file type 

- ์œˆ๋„์šฐ๋Š” ํŒŒ์ผ๋ช… ๋’ค์— ๋ถ™๋Š” ํ™•์žฅ์ž๋กœ file type ์ง€์ • (.exe, .mp3 ๋“ฑ)

- ์œ ๋‹‰์Šค๋Š” ํ™•์žฅ์ž๋ช…์ด ๋ณ„ ์˜๋ฏธ X, OS๊ฐ€ ๊ด€๋ฆฌํ•œ๋‹ค. 

 

* file access

1) sequential access – ์ˆœ์„œ๋Œ€๋กœ ๋ฐ”์ดํŠธ๋“ค์„ ์ฝ๋Š” ๊ฒƒ 2) direct access – ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ๋ฐ์ดํ„ฐ ์œ„์น˜๋กœ ๋ฐ”๋กœ ์ด๋™, random access  3) record access 4) index access 

 

- ์˜ˆ์‹œ index and relative files 

- ํฐ ํŒŒ์ผ์—์„œ ์ฐพ์„ ์ˆ˜ X -> ์ž‘์€ index file์—์„œ ๋‚ด๊ฐ€ ์–ป๊ณ  ์‹ถ์€ ์ •๋ณด๋ฅผ ์ฐพ์€ ๋’ค, ํ•ด๋‹น ์ •๋ณด์˜ ์œ„์น˜๋กœ ์ ‘๊ทผ 

- ์ž‘์€ Index file / ์›๋ž˜ ์ •๋ณด๊ฐ€ ์ €์žฅ๋œ ํฐ ํŒŒ์ผ == relative file (data file) 

- ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ์œ„์น˜๋กœ ๋‹จ๋ฒˆ์— ์ด๋™ -> direct access, ๋ ˆ์ฝ”๋“œ ๋‹จ์œ„๋กœ ์ ‘๊ทผ – record access, ํšจ์œจ์ ์œผ๋กœ ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•œ index access (3๊ฐ€์ง€ ๋‹ค ์ฐพ์„ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ) 

 

- directory์™€ ๊ด€๋ จ๋œ Unix operations – opendir, readdir, seekdir, closedir => ๋ชจ๋‘ system call

 

* file system mounting 

- window = drive letter ์•ŒํŒŒ๋ฒณ ์‚ฌ์šฉ (C:\, D:\ ๋“ฑ๋“ฑ)

- ์œ ๋‹‰์Šค/๋ฆฌ๋ˆ…์Šค = ์ „๋ถ€ root directory -> ๋นˆ directory ๋ฐ‘์— ์ƒˆ๋กœ์šด directory๋ฅผ ๋ถ™์ธ๋‹ค. -> ์‚ฐ ๊ฐ™์•„์„œ ๋งˆ์šดํŒ…

 

- file sharing – Remote File Sharing 

- NFS – network file system  ์œ ๋‹‰์Šค์˜ ํด๋ผ์ด์–ธํŠธ-์„œ๋ฒ„ ํŒŒ์ผ ๊ณต์œ  ํ‘œ์ค€ ํ”„๋กœํ† ์ฝœ 

- CIFS – windows์—์„œ ์‚ฌ์šฉํ•˜๋Š” ํ‘œ์ค€ ํ”„๋กœํ† ์ฝœ

 

* Protection 

1. Access control list (ACLs) – file ๋ณ„๋กœ, ์‚ฌ์šฉ์ž๋งˆ๋‹ค ๊ฐ€๋Šฅํ•œ ์—ฌ๋ถ€๋ฅผ ํ‘œ์‹œํ•œ ๋ฆฌ์ŠคํŠธ (์„ธ๋กœ ๋ฐฉํ–ฅ) 

- ์ง€๊ธˆ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹, ๋ชจ๋“  ์‚ฌ์šฉ์ž๋ฅผ ๋‹ค ํ‘œ์‹œํ•˜์ง€ ์•Š๊ณ , ์‚ฌ์šฉ์ž๋“ค์„ grouping

2. Capabilities – ์‚ฌ์šฉ์ž ๋ณ„๋กœ, ๋ชจ๋“  ํŒŒ์ผ์— ๋Œ€ํ•œ read, write ๋“ฑ๋“ฑ ๊ฐ€๋Šฅ์„ฑ ์—ฌ๋ถ€๋ฅผ ๋ฆฌ์ŠคํŠธ์— ์ €์žฅ 

- ํŒŒ์ผ์ด ํ•˜๋‚˜ ์ƒˆ๋กœ ์ƒ๊ธธ ๋•Œ ๋งˆ๋‹ค, ๋ชจ๋“  ์‚ฌ์šฉ์ž์—๊ฒŒ ์ž‘์—… -> ๋ณต์žก๋„๊ฐ€ ๋†’์•„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๋ฐฉ์‹ 

 

* Access list in Unix/Linux

- ์ ‘๊ทผ ๋ชจ๋“œ 3๊ฐ€์ง€ – read, write, execute

- ์œ ์ € class 3๊ฐ€์ง€ – owner access -> file์„ ๋งŒ๋“  ์ž๊ธฐ ์ž์‹  / group access -> ์ž์‹ ์ด ์†ํ•œ ๊ทธ๋ฃน์˜ ์‚ฌ๋žŒ๋“ค / public access – ๋ชจ๋“  ์‚ฌ๋žŒ๋“ค

 

owner access (RWX 111)  /  group access (RWX 110)  /  public access (RWX 001)  -> ํŒŒ์ผ ํ•˜๋‚˜ ๋‹น 9bit ํ•„์š”

 

ex1) chmod 761 game // 7 – owner, 6 – group, 1 – public (8์ง„์ˆ˜, 0~7๊นŒ์ง€ ์ตœ๋Œ€ 7 ํ‘œํ˜„)

== game์ด๋ž€ ํŒŒ์ผ์˜ permission์„ 761๋กœ ๋ฐ”๊พผ๋‹ค๋Š” ์˜๋ฏธ 

 

ex2) -rw-rw-r-- (owner, group, public)

    drwx------ (๋‚˜๋งŒ read, write, execute ๊ฐ€๋Šฅํ•˜๊ณ , ์•„๋ฌด๋„ X)

 

 

 

 

 

14. File System Implementation

15. File System Internals 

- ๊ฐœ๋ฐœ์ž ์ž…์žฅ์—์„œ์˜ file system 

 

1) in-memory structure

- OS๊ฐ€ ์ˆ˜ํ–‰๋˜๋Š” ๋™์•ˆ, ์–ด๋–ป๊ฒŒ file์„ application์—๊ฒŒ ์ œ๊ณตํ•˜๋Š”๊ฐ€? 

 

2) On-disk structure 

- ์ด๊ฒŒ ๋” ์ค‘์š”! ์ปดํ“จํ„ฐ ์ข…๋ฃŒ ํ›„์—๋„ ์œ ์ง€๋˜๋Š” ํŒŒ์ผ ์‹œ์Šคํ…œ

2-1) Boot control block – ๋ถ€ํŒ… ์‹œ ํ•„์š”ํ•œ ๊ฒƒ – Boot block (UFS) or Boot Sector (NTFS – ์œˆ๋„์šฐ) 

2-2) Volume control block – file system์— ๋Œ€ํ•œ ์ •๋ณด ์ €์žฅ – super block (UFS) / master file table (NTFS)

2-3) Directory structure 

2-4) File control block (FCB) – attribute ๊ด€๋ฆฌ – i-nodes (UFS), in master file table (NTFS)

 

* in-memory structure 

- ์ „์›์ด ์ผœ์ ธ, application process๊ฐ€ OS์—๊ฒŒ system call๋กœ ์š”์ฒญ

- process ๋ณ„ open file table ๊ฐ–๋Š”๋‹ค. (0 – standard input / 1 – standard output / 2 - standard error) 3๋ฒˆ๋ถ€ํ„ฐ file descripter -> process๊ฐ€ file open ํ•  ๋•Œ ๋งˆ๋‹ค, table์˜ entry๊ฐ€ ์ฆ๊ฐ€ํ•œ๋‹ค. 

- file table – ์ปค๋„์ด ๊ด€๋ฆฌํ•˜๋Š”, system wide open file table s

- memory์— ์กด์žฌํ•˜๋Š” data structure 

–> Buffer cache (directory cache – ๋””๋ ‰ํ† ๋ฆฌ ์ €์žฅ + buffer cache – file data ์ €์žฅ) 

-> HDD ํŒŒ์ผ ์ค‘ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ํŒŒ์ผ์„ main memory์— ์˜ฌ๋ ค ์‚ฌ์šฉ 

 

Virtual File System (VFS) – ๊ณตํ†ต์ธ ๋ถ€๋ถ„์„ VFS๋กœ ๊ด€๋ฆฌ

 

1) CD-ROM – read์— ์ตœ์ ํ™” ๋œ CD ROM์˜ ํŒŒ์ผ ์‹œ์Šคํ…œ – ISO 9660 ํ‘œ์ค€ – OS์™€ ๋ฌด๊ด€ํ•˜๊ฒŒ ์ •์˜๋จ

2) UNIX – UFS (์œ ๋‹‰์Šค ํŒŒ์ผ ์‹œ์Šคํ…œ), FFS (fast file system) 

3) Windows – FAT – file allocation table, FAT32(USB), NTFS (ํ˜„์žฌ ๋ชจ๋“  ์œˆ๋„์šฐ OS์˜ ํŒŒ์ผ ์‹œ์Šคํ…œ) 

4) Linux – ext2, 3, 4 – extended file system // ๊ธฐ์กด ์šด์˜์ฒด์ œ์™€ ํ˜ธํ™˜์„ ์œ„ํ•ด 130๊ฐœ์˜ ํŒŒ์ผ ์‹œ์Šคํ…œ ์กด์žฌ 

+) ZFS – embedded system – flash memory file system / ๋ถ„์‚ฐ ํ™˜๊ฒฝ์—์„œ์˜ ํŒŒ์ผ ์‹œ์Šคํ…œ 

 

* On-Disk Structure – HDD or SSD ๊ฑฐ์˜ ๋ณ€ํ•˜์ง€ X

- BIOS – MBR // UEFI (์ƒˆ๋กœ์šด ํ‘œ์ค€) – GPT // OS๊ฐ€ ๋ถ€ํŒ…๋  ์ˆ˜ ์žˆ๋Š” partition – active partition 

1) boot block – ๋ถ€ํŒ…๊ณผ ๊ด€๋ จ๋œ ์ •๋ณด ์ €์žฅ  ์ปค๋„์ด ์ €์žฅ๋จ 

2) super block – ํŒŒ์ผ ์‹œ์Šคํ…œ๊ณผ ๊ด€๋ จ๋œ ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ ์ €์žฅ (์ด ํŒŒ์ผ ์ˆ˜  ํŒŒ์ผ ์‹œ์Šคํ…œ์˜ ํฌ๊ธฐ, ํƒ€์ž… ๋“ฑ๋“ฑ) 

3) bitmaps – free space management 

4) i-nodes – file ํ•˜๋‚˜ํ•˜๋‚˜์— ๋Œ€ํ•œ metadata (FCB – file control block) / index ์˜๋ฏธ

5) ์ด ๋’ค๋Š” ๋ชจ๋‘ data – ์ œ์ผ ์ฒซ๋ฒˆ์งธ ๋ฐ์ดํ„ฐ๊ฐ€ root directory data // ์ดํ›„ ํŒŒ์ผ๊ณผ ๋””๋ ‰ํ† ๋ฆฌ ๋ฐ์ดํ„ฐ๋“ค ์ €์žฅ 

 

* ์œˆ๋„์šฐ์˜ format / UNIX – mkfs (make file system) -> ์œ„์™€ ๊ฐ™์€ ํŒŒ์ผ ์‹œ์Šคํ…œ์„ ํ•˜๋‚˜ ๋งŒ๋“ฆ 

 

- Disk block – HDD์˜ cylinder, surface, track, sector ์˜์—ญ์˜ ๋„˜๋ฒ„ ํ‘œํ˜„ -> disk block ๋„˜๋ฒ„๋กœ mapping 

-> OS์—์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด disk block ๋‹จ์œ„๋กœ ๊ด€๋ฆฌํ•œ๋‹ค. (ํฌ๊ธฐ๋Š” 4KB)

- ์ด๋Ÿฌํ•œ ๋งคํ•‘ ๊ด€๋ฆฌ๋Š” disk controller๊ฐ€ ํ•œ๋‹ค. ์šด์˜์ฒด์ œ๋Š” 0๋ฒˆ๋ถ€ํ„ฐ 1M – 1 ๊ฐœ์˜ ๋””์Šคํฌ block์„ ๊ด€๋ฆฌํ•œ๋‹ค. 

- 4GB HDD๊ฐ€ ์žˆ์„ ๋•Œ, 4KB์˜ ๋””์Šคํฌ block์ด 1M๊ฐœ (2^20๊ฐœ) ์ƒ๊ธด๋‹ค. 

 

* Free Space Management – bitmap block // ์‚ฌ์šฉ ์ค‘ 1 or not 0 -> block ๋‹น 1 bit๋กœ ํ‘œํ˜„ ๊ฐ€๋Šฅ 

- block size – 4KB (2^12 byte), disk size – 1GB (2^30 byte) -> 2^18 bit ๊ฐœ (byte๋กœ ๋ณ€ํ™˜ ์‹œ, 2^15 byte, 32KB)

-> ์ด๋Ÿฌํ•œ ์ˆ˜์˜ disk block๋“ค์„ ์–ด๋–ป๊ฒŒ ๊ด€๋ฆฌํ•  ๊ฒƒ?

 

- Linked list (free list) – HDD๋Š” flash memory ๊ธฐ๋ฐ˜์˜ SSD๋ณด๋‹ค ๋” ๊นจ์ง€๊ธฐ ์‰ฝ๋‹ค (์ถฉ๊ฒฉ์— ์•ฝํ•จ) 

-> ์ด ๋ฐฉ๋ฒ•์€ ์ž˜ ์‚ฌ์šฉํ•˜์ง€ X / bit map ๋ฐฉ์‹ ํ™œ์šฉ // ์ค‘๊ฐ„์— ๊ณ ์žฅ ๋‚˜๋ฉด, ๊ทธ ๋’ค๋Š” ์‹น ๋‚ ๋ผ๊ฐ 

- ZFS – ๋น…๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๋ถ„์‚ฐ ํŒŒ์ผ ์‹œ์Šคํ…œ / space map๊ณผ ๊ฐ™์€ ๋‹ค๋ฅธ ์ž๋ฃŒ ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

 

* File control block (FCB) – i-nodes – ํŒŒ์ผ์ด ํ•˜๋‚˜ ์ƒ์„ฑ๋  ๋•Œ ๋งˆ๋‹ค ์•„๋ž˜์˜ ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅ -> FCB

- ์œˆ๋„์šฐ OS์˜ ๊ฒฝ์šฐ master file table // UNIX – i-nodes (UFS – Unix file system)

 

- directory implementation – ๋””๋ ‰ํ† ๋ฆฌ๋Š” ์–ด๋–ค ๋ฐ์ดํ„ฐ ์ €์žฅ? 1) file ์ด๋ฆ„ 2) file์˜ metadata (FCB)

1) in the directory table – ํŒŒ์ผ ์ด๋ฆ„๊ณผ ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ๋ฅผ ์‹น ๋‹ค ์ €์žฅํ•˜๋Š” ๋ฐฉ์‹

2) in the separate data structure (i-nodes) // UNIX / LINUX์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹ 

- ํŒŒ์ผ ์ด๋ฆ„๊ณผ, FCB(i-nodes)์˜ ์œ„์น˜๋ฅผ ์ €์žฅํ•œ๋‹ค. -> ๋”ฐ๋ผ๊ฐ€๋ฉด ๋ฉ”ํƒ€ ๋ฐ์ดํ„ฐ๊ฐ€ ๋‚˜์˜ค๋Š” ๊ฒƒ 

3) a hybrid approach – ์œˆ๋„์šฐ  ํŒŒ์ผ ์ด๋ฆ„๊ณผ + FCB ์œ„์น˜์™€ + ๋”๋ถˆ์–ด ์ค‘์š” ์ •๋ณด๊นŒ์ง€ ์ค‘๋ณต์œผ๋กœ ์ €์žฅ 

Ex) ์œˆ๋„์šฐ ํƒ์ƒ‰๊ธฐ์—์„œ ํŒŒ์ผ์— ๋Œ€ํ•œ ๊ฐ„๋žตํ•œ ์ •๋ณด๋ฅผ ๋„์šธ ๋•Œ – FCB์™€ ๊ฒน์น˜๋Š” ๋‚ด์šฉ์„ ์ž‘๊ฒŒ ์ €์žฅํ•˜๊ณ  ์žˆ์Œ 

 

* Allocation methods – file data๊ฐ€ ์–ด๋–ป๊ฒŒ ๊ด€๋ฆฌ๋˜๋Š”๊ฐ€? 

- ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฒƒ์€, ์ด file data๊ฐ€ ์–ด๋””์— ์ €์žฅ๋˜์—ˆ๋Š” ์ง€ ์•„๋Š” ๊ฒƒ 

Ex) file size 40KB -> 4KB ํฌ๊ธฐ์˜ disk block 10๊ฐœ๊ฐ€ ํ•„์š”ํ•œ ๊ฒƒ -> ์ด๊ฒŒ ์–ด๋””์— ์–ด๋–ป๊ฒŒ ์ €์žฅ๋˜๋Š”๊ฐ€? 

-> 4MB, MP3์˜ ๊ฒฝ์šฐ 1K ๊ฐœ๊ฐ€ ํ•„์š”ํ•˜๋‹ค. 

-> contiguous / linked / indexed allocation ๋ฐฉ์‹์ด ์กด์žฌํ•œ๋‹ค. 

 

1) Contiguous allocation / ์‹œ์ž‘ ์œ„์น˜์™€ ๊ธธ์ด๋งŒ ์žˆ์œผ๋ฉด ์ฐพ์„ ์ˆ˜ ์žˆ๋‹ค  ์‰ฝ๊ณ , simple ํ•˜๋‹ค๋Š” ์žฅ์  

- file ์ด๋ฆ„ + FCB (file control block์— ์‹œ์ž‘ ์œ„์น˜์™€ ๊ธธ์ด ์ €์žฅ) 

- file์— data๊ฐ€ ์ถ”๊ฐ€๋  ๊ฒฝ์šฐ, ํŒŒ์ผ์ด ๋” ์ปค์ง€๋ฉด ์ˆ˜์ •์ด ์–ด๋ ค์›€ -> ์—ฐ์†์œผ๋กœ block๋“ค์„ ์ €์žฅํ•˜๋‹ค ๋ณด๋‹ˆ, ๋” ํฐ ๋นˆ๊ณต๊ฐ„์œผ๋กœ ์˜ฎ๊ฒจ์•ผ ํ•จ  ํŒŒ์ผ์ด ์ƒ์„ฑ๋˜๊ณ , ์‚ฌ๋ผ์ง€๋Š” ํ™˜๊ฒฝ์—์„œ๋Š” ์‚ฌ์šฉํ•˜๊ธฐ ์–ด๋ ต๋‹ค. // dynamic allocation ๋‹จ์ 

Ex) ์ฝ๊ธฐ ์ „์šฉ CD-ROM์— ์‚ฌ์šฉ 

 

2) Linked Allocation / ์—ฐ์†์  ๋ฐฐ์น˜๋ฅผ ๋ถˆ์—ฐ์†์ ์œผ๋กœ ๋ฐฐ์น˜ 

- block์€ ์ž์‹ ์˜ ๋ฐ์ดํ„ฐ์™€ ํ•จ๊ป˜ ๋‹ค์Œ block์˜ ์œ„์น˜๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ํฌ์ธํ„ฐ๋ฅผ ์ €์žฅํ•œ๋‹ค.

- ์ด ๋˜ํ•œ ํŒŒ์ผ ์ด๋ฆ„๊ณผ ์‹œ์ž‘ block ์œ„์น˜๋งŒ ์ €์žฅํ•˜๋ฉด ๋˜์–ด, ํ‘œ๊ธฐํ•˜๊ธฐ ์‰ฝ๋‹ค๋Š” ์žฅ์ ์ด ์žˆ๋‹ค. 

+ contiguous์™€ ๋‹ฌ๋ฆฌ, dynamicํ•œ ํŒŒ์ผ์—๋„ ์ ์šฉ ๊ฐ€๋Šฅํ•œ ์žฅ์ 

- ๋‹จ์  – sequentialํ•˜๊ฒŒ ์ €์žฅ๋œ ์‹คํ–‰ ํŒŒ์ผ์€ OK -> data file, random access -> ์•ž๋ถ€ํ„ฐ ๋‹ค ์ฝ์–ด์•ผ ํ•˜๋Š” ๋ฌธ์ œ์  

+ ์ค‘๊ฐ„์— ๊ณต๊ฐ„์ด ํ•˜๋‚˜ ๋‚ ๋ผ๊ฐ€๋ฉด ๋ชป์“ด๋‹ค. ์‹ ๋ขฐ๋„ ์ธก๋ฉด์—์„œ ํฌ์ธํ„ฐ๊ฐ€ ์†์ƒ๋  ๊ฒฝ์šฐ, ์‹ ๋ขฐ๋„ ์ธก๋ฉด์—์„œ ๋ฌธ์ œ 

 

+ File Allocation Table (FAT)

- ์ด์ „ ๋ฐฉ์‹์—์„œ block์˜ pointer ๋“ค์„ ๋ชจ๋‘ ๋ชจ์•„์„œ, ๋ณ„๋„์˜ ํ…Œ์ด๋ธ”๋กœ ๋งŒ๋“ค์–ด ๊ด€๋ฆฌ // 2~3 ์ค‘์œผ๋กœ ๊ด€๋ฆฌ 

- ์ž‘์•„์„œ ๋ฉ”์ธ ๋ฉ”๋ชจ๋ฆฌ์— ํ…Œ์ด๋ธ”์„ ์˜ฌ๋ฆฌ๊ณ  cache // linked allocation์˜ random access ๋ฌธ์ œ๋„ ํ•ด๊ฒฐ ๊ฐ€๋Šฅ

- ํ•˜์ง€๋งŒ ์—ฌ์ „ํžˆ ์‹ ๋ขฐ๋„ ๋ฌธ์ œ ์กด์žฌ

 

+ FAT16 (DOS ์‹œ์ ˆ, disk block์„ ํ‘œํ˜„ํ•˜๋Š” ํฌ๊ธฐ๊ฐ€ 16 bit) 

vs FAT32 (32 bit๋กœ ๋Š˜๋ฆฐ ๊ฒƒ, USB์—์„œ ์‚ฌ์šฉ, ์œˆ๋„์šฐ๋Š” ์—ฌ๊ธฐ์—์„œ NTFS๋กœ ๋„˜์–ด๊ฐ„ ๊ฒƒ) 

 

3) Indexed Allocation – i-nodes -> index node 

- ๋ณ„๋„์˜ disk block์— ์ญ‰ ์ €์žฅ / ์ด ํŒŒ์ผ์ด ์–ด๋”” ์žˆ๋Š”์ง€ / ๋‚ ๋ผ๊ฐ€๋”๋ผ๋„ ์ด ํŒŒ์ผ ํ•˜๋‚˜๋งŒ ๋‚ ์•„๊ฐ 

- random access ์šฉ์ด // reliability ์žฅ์  

-> ์˜ํ™”์ฒ˜๋Ÿผ ํฐ ์• ๋“ค์€ ์–ด๋–ป๊ฒŒ ์ €์žฅ? 

 

* Indexed allocation – combined scheme – UFS (block์€ 4KB, ์ฃผ์†Œ๋Š” 32 bit – 4Byte)

1) direct blocks – data ์œ„์น˜๊ฐ€ ์–ด๋””์— ์žˆ๋Š”์ง€ ์ง์ ‘ ์“ฐ๋Š” ๊ฒƒ / 12๊ฐœ, ์ฆ‰ 48KB๊นŒ์ง€ ์ปค๋ฒ„ ๊ฐ€๋Šฅ) 

2) single indirect – 32bit integer – 4byte -> 4KB disk block ํ•˜๋‚˜์—, 1K๊ฐœ์˜ block address ํ‘œํ˜„ ๊ฐ€๋Šฅ (1024๊ฐœ)

-> ๋”ฐ๋ผ์„œ 1K๊ฐœ * 4KB (4MB) ์ปค๋ฒ„ ๊ฐ€๋Šฅ 

3) double indirect – single indirect ๊ตฌ์กฐ๊ฐ€ 1K ๊ฐœ -> 4B * 1K * 1K = 4GB

4) triple indirect – 4B * 1K * 1K * 1K = 4TB

 

* Unix file system (UFS) ๊ตฌ์กฐ  ์•„์ฃผ ๋งŽ์€ disk block์„ ์ฝ์–ด์•ผ ์‹คํ–‰ ๊ฐ€๋Šฅ 

i-node(0): root directory -> root data์˜ ๋ฒˆ์ง€ ์ˆ˜๋ฅผ ์ฐพ์•„ ๊ฐ„๋‹ค. -> directory ์—์„œ /bin ์„ ์ฐพ์•„ ์ฝ๋Š”๋‹ค -> /bin์˜ i-node -> ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ์˜ data๋ฅผ ์ €์žฅํ•˜๋Š” directory์—์„œ ๋‚ด๊ฐ€ ์ฝ์–ด์•ผ ํ•  ํŒŒ์ผ a.out์˜ ์œ„์น˜๋ฅผ ์ฐพ๋Š”๋‹ค -> a.out์˜ i-node -> ์—ฌ๊ธฐ์— single direct block 12๊ฐœ + double indirect block ๋“ฑ๋“ฑ 

- ls ๋ช…๋ น์–ด -> ์ฒ˜์Œ์—๋Š” HDD์—์„œ ์ฝ์Œ -> ์ดํ›„ ๋ฉ”์ธ ๋ฉ”๋ชจ๋ฆฌ์— cache -> ์„ฑ๋Šฅ ํ–ฅ์ƒ 

 

* Block size performance vs efficiency 

- block size ํฌ๊ธฐ๊ฐ€ ํด์ˆ˜๋ก, HDD๋Š” ํ•œ๋ฒˆ ์›€์ง์—ฌ ๋งŽ์ด ์ฝ์–ด์•ผ ํ•˜๋‹ˆ๊นŒ ์„ฑ๋Šฅ์ด ์ฆ๊ฐ€ํ•œ๋‹ค. 

- ํ•˜์ง€๋งŒ ์„ฑ๋Šฅ ์ธก๋ฉด์—์„œ, block size๊ฐ€ ์ฆ๊ฐ€ํ•˜๋ฉด internal fragmentation ์ฆ๊ฐ€ -> utilization ๊ฐ์†Œ

- ์„ฑ๋Šฅ๊ณผ utilization์ด trade off๊ฐ€ ์žˆ๋‹ค -> ํ˜„์žฌ ์ ์ ˆํ•œ 4KB๋กœ disk block size๊ฐ€ ์ •ํ•ด์ง 

+ SSD = ์ „๊ธฐ์  ๋™์ž‘์œผ๋กœ, ๋งŽ์ด ์ฝ๋Š” ๊ฒƒ๊ณผ ๋ฌด๊ด€ํ•˜๋‹ค. ๋”ฐ๋ผ์„œ utilization๋งŒ ๊ณ ๋ คํ•˜๋ฉด ๋œ๋‹ค. 

 

* Read ahead – sequentialํ•˜๊ฒŒ ์ฝ์„ ๊ฒฝ์šฐ, ํŒŒ์ผ ์‹œ์Šคํ…œ์ด ํ”„๋กœ์„ธ์Šค๊ฐ€ ํ•„์š”ํ•  disk block๋“ค์„ ๋ฏธ๋ฆฌ ์ฝ์–ด, cache

 

* Buffer Cache – HDD์—์„œ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๋“ค์„ main memory์— cache (SSD๋„ ์บ์‹œ ํšจ๊ณผ์ ) 

- 4MB๋งŒ ์บ์‹œ ํ•˜๋”๋ผ๋„, ๋งค์šฐ ํšจ๊ณผ์ ์ด๋‹ค. 

- Synchronous write – ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์บ์‹œ์— ์“ฐ๊ณ , HDD์—๋„ ๋™์‹œ์— ์“ฐ๋ฉด  ์„ฑ๋Šฅ ํ–ฅ์ƒ X (write through)

- Asynchronous write – ๋ชจ๋‘ ๋ชจ์•„ ํ•œ๋ฒˆ์— HDD์— ์“ฐ๋ฉด ์„ฑ๋Šฅ ํ–ฅ์ƒ O (Write behind, write back)

-> ํ•˜์ง€๋งŒ unreliable – main memory๋งŒ ๋ฐ”๋€Œ๊ณ , HDD๋Š” ๋ฐ˜์˜๋˜์ง€ ์•Š์•˜๋Š”๋ฐ, ์ •์ „ or ๋น„์ •์ƒ์ ์ธ ์ข…๋ฃŒ ๋ฐœ์ƒ ๋“ฑ 

 

* Reliability – ๋ณต๊ตฌํ•˜๋Š” ๊ฒƒ – utility ํ”„๋กœ๊ทธ๋žจ์ด ํŒŒ์ผ ์‹œ์Šคํ…œ์˜ ์ผ๊ด€์„ฑ์„ ์ฒดํฌํ•˜๋Š” ๊ฒƒ 

UNIX – fsck (file system check) // Window – scandisk -> ๋น„์ •์ƒ์ ์ธ ์ข…๋ฃŒ๋ฅผ ๋ณต๊ตฌ 

 

* Journaling file system (Log Structured File Systems) 

- Linux ext3 ์ดํ›„ // ์œˆ๋„์šฐ NTFS ๋“ฑ  ํ˜„์žฌ OS๋“ค์ด ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹ 

- ํŒŒ์ผ ๋ณ€๊ฒฝ์— ๋Œ€ํ•œ ์š”์•ฝ ์ •๋ณด๋งŒ journal์ด๋ผ๋Š” ๊ณณ์— ์ €์žฅ -> ์ดํ›„ HDD์— ์“ฐ๊ณ , ์ €๋„์€ ์‚ญ์ œ 

- ๋ถ€ํŒ… ์‹œ ์ €๋„์ด ๋น„์–ด์•ผ ์ •์ƒ / ์ €๋„์ด ์ฐจ ์žˆ๋‹ค๋ฉด -> HDD์—๋Š” ์“ฐ์ง€ ์•Š์€ ์ƒํƒœ์ธ ๊ฒƒ -> ๋น„์ •์ƒ์ ์ธ ์ƒํ™ฉ์„ ๊ฐ์ง€ํ•  ์ˆ˜ ์žˆ๋‹ค. 

 

* remote file system 

-> ๋„คํŠธ์›Œํฌ๋กœ ์—ฐ๊ฒฐ๋œ ์ปดํ“จํ„ฐ์˜ ํŒŒ์ผ ์‹œ์Šคํ…œ์„ ๋งˆ์น˜ ๋‚ด ํŒŒ์ผ ์‹œ์Šคํ…œ์ฒ˜๋Ÿผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ 

- VFS (virtual file system) – ๊ณตํ†ต์ธ ๊ฒƒ์— ๋Œ€ํ•œ interface 

- NFS (network file system)  ๋งˆ์šดํŠธํ•˜์—ฌ ๋‚ด ์ปดํ“จํ„ฐ์—์„œ ๋กœ์ปฌ ํŒŒ์ผ ์‹œ์Šคํ…œ์ฒ˜๋Ÿผ ์‚ฌ์šฉ ๊ฐ€๋Šฅ 

+ RPC – ๋‹ค๋ฅธ ์ปดํ“จํ„ฐ์˜ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰์‹œํ‚ค๊ธฐ ์œ„ํ•œ C/Cpp ๊ธฐ์ˆ  ์˜๋ฏธ (remote procedure call)

 

 

 

 

 

16. Security 

- Security requirement triad (CIA triad)

1. Confidentiality – ๊ธฐ๋ฐ€์„ฑ, ์•”ํ˜ธํ™” / 2. Integrity – ๋ฌด๊ฒฐ์„ฑ, ๋ณ€์กฐ๋˜์ง€ ์•Š์Œ / 3. Availability – ๊ฐ€์šฉ์„ฑ (์„œ๋น„์Šค ์ฃฝ์ŒX)

 

* ์šฉ์–ด ์ •๋ฆฌ 

- Vulnerability – ์ทจ์•ฝ์  / Threat – ์œ„ํ˜‘ / Attack – ๊ณต๊ฒฉ / Adversary – ์ , attacker / Countermeasure – ๋Œ€์‘์ฑ…

- CIA + Authentication – ์ธ์ฆ / Access control – ์ ‘๊ทผ ๊ถŒํ•œ / Nonrepudiation  ๋ถ€์ธ ๋ฐฉ์ง€ 

 

* Cracker’s basic step 

1. gather information 2. Use port scanner 3. Get a login account – authentication์„ ํ†ตํ•ด ์ ๋ฒ•ํ•œ ์‚ฌ์šฉ์ž๊ฐ€ ๋จ 
4. Get root privilege – 
๋ฃจํŠธ ๊ถŒํ•œ์„ ์–ป๋Š” ๊ฒƒ์€ ์–ด๋ ต์ง€ ์•Š๋‹ค 5. Backdoor – ์–ธ์ œ๋“ ์ง€ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ฐฑ๋„์–ด 

 

* Physical security 

1) Hardware security – ์‹œ์Šคํ…œ, ํ•˜๋“œ์›จ์–ด ์‚ฌ์šฉ์— ๋Œ€ํ•œ ๋ณด์•ˆ – smart card / bio-metric access control 

2) BIOS security – ๋ถ€ํŒ… ์‹œ firmware ๋‹จ๊ณ„์—์„œ ๋น„๋ฐ€๋ฒˆํ˜ธ  ์•„๋ฌด๋„ ์ด๋ ‡๊ฒŒ ์‚ฌ์šฉ X

3) Session security – ํšŒ์‚ฌ์—์„œ ์ž๋ฆฌ ๋น„์šธ ๋•Œ, screen saver 

 

* Account security 

1) Authentication – ์ธ์ฆ – password – CHAP (Challenge Handshake Authentication protocol) 
- 
๋ณต์žกํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋กœ ์„ค์ •ํ•˜์—ฌ, brute force๋กœ ๊นฐ ์ˆ˜ ์—†๋„๋ก ์ตœ๊ทผ์— ์‚ฌ์šฉ

2) Authorization – ๊ถŒํ•œ – access control – Access Control List (ACLs) vs Capabilities (์‚ฌ์šฉ์ž ๋ณ„) 

 

* File System Security – Unix, Linux 

– setuid, setgid – ๋ณด์•ˆ์— ์ทจ์•ฝํ•œ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ํŠน๋ณ„ํžˆ ์ž˜ ๊ด€๋ฆฌํ•ด์•ผ ํ•จ 

- search path๋ฅผ ์ด์šฉํ•œ ๊ณต๊ฒฉ ๋“ฑ ๋‹ค์–‘ํ•œ ๊ณต๊ฒฉ์ด ์žˆ์—ˆ๋‹ค -> ์ด์— ๋Œ€ํ•œ ๋‹ค์–‘ํ•œ countermeasures (๋Œ€์‘์ฑ…) ์กด์žฌ 

 

* Network Security - File System Security๋ณด๋‹ค ๋” ์ค‘์š”

1) application layer – https๋ฅผ ์‚ฌ์šฉํ•ด๋ผ

2) transport layer – SSL (Secure socket layer) 

3) Network layer – IPSec Protocol – IPv6์€ ํ•„์ˆ˜, 4๋Š” optional – IPv4 ์„ธ์ƒ -> ์ œ๋Œ€๋กœ ์‚ฌ์šฉ๋˜๊ณ  ์žˆ์ง€ X

 

- TCP Wrapper – ํŠน์ • IP/Port ์—์„œ๋งŒ ๋“ค์–ด์˜ฌ ์ˆ˜ ์žˆ๋‹ค. ๋‹ค๋ฅธ ๊ฒฝ๋กœ๋ฅผ deny ๊ฐ€๋Šฅ 

- Firewall (๋ฐฉํ™”๋ฒฝ) – ๋ณ„๋„์˜ ์žฅ๋น„๋ฅผ ํ™œ์šฉํ•˜์—ฌ network security – public internet์—์„œ ๊ฒฝํฌ๋Œ€๋กœ ์˜ค๋Š” Packet ์ค‘ ์ด์ƒํ•œ packet์€ drop ๊ฑฐ๋ฅด๊ณ , ์ ํ•ฉํ•œ packet๋งŒ ๋“ค์—ฌ๋‹ค ๋ณด๋‚ธ๋‹ค. 

+ DMZ – ์™ธ๋ถ€ ์‚ฌ์šฉ์ž์—๊ฒŒ ์„œ๋น„์Šค ์ œ๊ณต ์‹œ, ๋‚ด๋ถ€ ์ธํŠธ๋ผ๋„ท์€ ์ ‘๊ทผ ๋ถˆ๊ฐ€๋Šฅ, DMZ๋ฅผ ํ†ตํ•ด ์„œ๋น„์Šค ์ œ๊ณต

 

- detection – ์นจ์ž… ๊ฐ์ง€ vs prevention ์›์ฒœ ๋ด‰์‡„ 

- IDS – Intrusion Detection System – ์„œ๋ฒ„ ๋ฐ ๋ฐฉํ™”๋ฒฝ์— ์ˆ˜ํ–‰ / ์ธ๊ณต์ง€๋Šฅ, ๋”ฅ๋Ÿฌ๋‹ 

- IPS – Intrusion Prevention System – WIPS – ํŠน์ • ์ง€์—ญ LTE ๋Š๊น€ 

 

* Security Treats 

- Physical threats – ์ž์—ฐ ์žฌํ•ด / Logical threats – ์ปดํ“จํ„ฐ ์†Œํ”„ํŠธ์›จ์–ด ๋ฒ„๊ทธ, ์ทจ์•ฝ์  // ์‚ฌ๋ผ์งˆ ์ˆ˜ X 

- Operational threats – ๊ด€๋ฆฌ์ž ์‹ค์ˆ˜ / Denial of service – ์ปดํ“จํ„ฐ์˜ ์„œ๋น„์Šค ์ œ๊ณต์„ ๋ง‰๋Š” ๊ฒƒ (DOS) 

 

* Attacks 

- Virus – ํ˜ผ์ž์„œ ์‹คํ–‰ X, ๋‹ค๋ฅธ ํ”„๋กœ๊ทธ๋žจ์— ๊ธฐ์ƒ / Worm – ๋…๋ฆฝ์ ์ธ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ๋ฒˆ์‹ ๊ฐ€๋Šฅ -> ๋‘˜ ๋‹ค ์•…์„ฑ์ฝ”๋“œ

- Trojan horses ํŠธ๋กœ์ด ๋ชฉ๋งˆ  ์žฌ๋ฏธ์žˆ๋Š” ๋‹ค์šด๋กœ๋“œ  ๋ฉ€์›จ์–ด ์„ค์น˜ / Logic bomb – ๊ฐœ๋ฐœ์ž ํ•ด๊ณ  ์‹œ ์‹œ์Šคํ…œ ๋‚ ๋ผ๊ฐ 

- Trap door – backdoor ๋ชฐ๋ž˜ ๋“ค์–ด๊ฐˆ ๊ฒฝ๋กœ ๋šซ๊ธฐ / Dictionary attack – brute force๋กœ password ๊นจ๊ธฐ

- Logic spoofing – ํ”ผ์‹ฑ 

 

- Malware – ์•…์„ฑ์ฝ”๋“œ / Spyware – ์ค‘์š” ์ •๋ณด ๋นผ๊ฐ€๊ธฐ / Ransomware – ์ค‘์š” ๋ฌธ์„œ ์•”ํ˜ธํ™”, ๋ˆ ์š”๊ตฌ

- Keystroke logger – ์‚ฌ์šฉ์ž์˜ ๋ชจ๋“  ์ž…๋ ฅ ์ „๋‹ฌ / Code injection – ๋ฉ€์›จ์–ด๋ฅผ ์‹œ์Šคํ…œ์— ์ฃผ์ž…

- Dos / DDos – distributed denial of system – ๋ถ„์‚ฐ์ ์œผ๋กœ dos ๊ณต๊ฒฉ 

 

* the Morris Internet Worm – ์„ธ๊ณ„ ์ตœ์ดˆ๋กœ UNIX ๋ฉ€์›จ์–ด ๊ฐœ๋ฐœ  ์Šค์Šค๋กœ ๋ณต์ œํ•˜๋Š” worm ํ”„๋กœ๊ทธ๋žจ

- finger์˜ bug๋ฅผ ํ†ตํ•ด worm ์ฃผ์ž… (code injection) 

-> ํ˜„์žฌ ์ด system์— ๋กœ๊ทธ์ธํ•œ ์‚ฌ์šฉ์ž๋“ค์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ์„œ๋น„์Šค 

 

* Buffer overflow – finger ์„œ๋น„์Šค๊ฐ€ ๋ฒ„ํผ ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ ์ทจ์•ฝ์ ์ด ์žˆ์—ˆ๋‹ค. 

- ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ปค๋งจ๋“œ๊ฐ€ argv[1]์— ๋“ค์–ด๊ฐ -> B๋ผ๋Š” array์— ์ž…๋ ฅ์„ copyํ•˜๊ณ , ํ™”๋ฉด์— ์ถœ๋ ฅ

-> 1024๋ณด๋‹ค ๋” ๋งŽ์€ ๋ฐ”์ดํŠธ๊ฐ€ ๋“ค์–ด๊ฐ€๋ฉด? 

 

* Code injection ๊ณผ์ • 

- main ํ•จ์ˆ˜๋ถ€ํ„ฐ stack์— ์Œ“์ž„ -> A๋ผ๋Š” ํ•จ์ˆ˜ ํ˜ธ์ถœ ์‹œ, A์˜ local ๋ณ€์ˆ˜๋“ค์„ ์œ„ํ•œ ๊ณต๊ฐ„๋„ ์Šคํƒ์— ์Œ“์ž„

- Buffer B ๊ณต๊ฐ„๋„ (1024 byte) ์Šคํƒ์— ์žกํž˜ // Code segment์˜ ์–ด๋”˜๊ฐ€๋กœ return ๋  return address ๊ณต๊ฐ„

- ์‚ฌ์šฉ์ž๊ฐ€ 1024 ์ด์ƒ์˜ ์ž…๋ ฅ์„ ๋„ฃ์œผ๋ฉด buffer๊ฐ€ ๋” ์œ„๋กœ write ๋จ -> return address ์˜์—ญ ์นจ๋ฒ”

-> ์ž˜ ๊ณ„์‚ฐํ•ด์„œ, ๋‚ด๊ฐ€ ์ž…๋ ฅํ•œ ๊ณณ์œผ๋กœ jump -> code ์˜์—ญ์œผ๋กœ return์ด ์•„๋‹ˆ๋ผ ์ž๊ธฐ ์ž์‹ ์œผ๋กœ ๋Œ์•„๊ฐ€๋„๋ก

-> hello world ์ž๋ฆฌ์— ์•…์„ฑ ์ฝ”๋“œ ์‹คํ–‰ ํ”„๋กœ๊ทธ๋žจ์„, ์ฆ‰ ์ฝ”๋“œ๋ฅผ ์ญ‰ ์“ด ๊ฒƒ 

* ๊ทธ๋ƒฅ ๋Œ์•„๊ฐ€๋Š” ์ฝ”๋“œ๊ฐ€ ์•„๋‹Œ, ์ทจ์•ฝ์ ์ด ์—†๋„๋ก Secure coding์„ ํ•ด์•ผ ํ•œ๋‹ค!

 

* IP Spoofing – IP address๋ฅผ ์†์ด๋Š” ๊ฒƒ 

- cracker๋Š” HOST B์— ์ ‘์†ํ•˜๊ณ  ์‹ถ์œผ๋‚˜, ๋ฐ”๋กœ ์ ‘์†ํ•  ์ˆ˜ ์—†์Œ 

- HOST A๋Š”, cracker๊ฐ€ ์•Œ๊ณ  ์žˆ์œผ๋ฉฐ, HOST B์— ์ ‘์† ๊ฐ€๋Šฅ 

- Denial of Service attack์œผ๋กœ A๋ฅผ ๋ฌด๋ ฅํ™” -> A์ธ ๊ฒƒ ์ฒ˜๋Ÿผ cracker๊ฐ€ B๋กœ ํŒจํ‚ท์„ ๋ณด๋ƒ„ 

- A๋Š” ๋ฌด๋ ฅํ™”๋˜์–ด ack๋ฅผ ๋ชป ๋‚ ๋ฆผ -> cracker์˜ IP address๋„ B์— ์ ‘์† ๊ฐ€๋Šฅํ•˜๋„๋ก ์กฐ์ž‘ 

 

* Denial of service attack – ์„œ๋น„์Šค๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•˜๋„๋ก ๋ง‰์Œ 

1) internal attack – ๋ฌดํ•œํžˆ Process ์ƒ์„ฑ – system ๋‹ค์šด, ๋งˆ๋น„์‹œํ‚ค๊ธฐ / fork, malloc์œผ๋กœ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์—„์ฒญ ๋งŽ์ด ์”€

2) external attack – packet์„ ๋ณด๋‚ด๋Š” ๊ฒƒ  ๋ฐฉํ™”๋ฒฝ์œผ๋กœ discard (IDS) ๊ฐ€๋Šฅ

-> DDos์ธ ๊ฒฝ์šฐ, ๋ฐฉํ™”๋ฒฝ์—์„œ ๊ฐ์ง€ํ•  ์ˆ˜ ์—†์Œ. //

 

* Basic concept of Cryptography 

1. Shared Key cryptography – AES ์•Œ๊ณ ๋ฆฌ์ฆ˜

- ๋™์ผํ•œ shared key๋ฅผ ์„œ๋กœ ๋‚˜๋ˆ  ๊ฐ–๊ณ , ์•”ํ˜ธํ™” ๋ฐ ๋ณตํ˜ธํ™”๋ฅผ ํ•œ๋‹ค. (ํ‚ค๋ฅผ ๊ฐ€์ง„ ์‚ฌ๋žŒ๋งŒ ์›๋ฌธ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.) 

- ์–ด๋–ป๊ฒŒ shared key๋ฅผ ๊ณต์œ ํ•  ๊ฒƒ์ธ๊ฐ€? ๊ฐ€ ์ด์Šˆ

- ์ƒ๋Œ€์ ์œผ๋กœ ์˜ค๋ฒ„ํ—ค๋“œ๊ฐ€ ์ž‘์•„, ๊ธด ์žฅ๋ฌธ์˜ text๋ฅผ ์•”ํ˜ธํ™”ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. 

 

2. Public Key cryptography – RSA ์•Œ๊ณ ๋ฆฌ์ฆ˜ 

- ๋ˆ„๊ตฌ๋‚˜ ๋‹ค ์•Œ ์ˆ˜ ์žˆ๋Š” public key์™€ ์ž๊ธฐ ์ž์‹ ๋งŒ ์•„๋Š” private key

2-1) Confidentiality – A๊ฐ€ B์˜ ๊ณต๊ฐœํ‚ค๋กœ ์•”ํ˜ธํ™” – B๋งŒ ๋ณตํ˜ธํ™” ๊ฐ€๋Šฅ (๊ธฐ๋ฐ€์„ฑ)

2-2) Authentication – A๊ฐ€ ์ž์‹ ์˜ private key๋กœ ์•”ํ˜ธํ™”  ๋ˆ„๊ตฌ๋‚˜ ๋ณตํ˜ธํ™” ๊ฐ€๋Šฅ – A๊ฐ€ ๋งŒ๋“  ๋ฌธ์„œ์ž„์„ ์ฆ๋ช… 

- AES๋ณด๋‹ค RSA๊ฐ€ ์—„์ฒญ๋‚˜๊ฒŒ ๋งŽ์€ ๊ณ„์‚ฐ๋Ÿ‰  ์˜ค๋ฒ„ํ—ค๋“œ ํฌ๊ณ , ์‹œ๊ฐ„๋„ ์˜ค๋ž˜ ๊ฑธ๋ฆผ / ๋น„๊ต์  ์ž‘์€ data ์•”ํ˜ธํ™”์— ์‚ฌ์šฉ

 

* Network ์•”ํ˜ธํ™” (TLS/SSL) – ์›น ๋ธŒ๋ผ์šฐ์ €(ํด๋ผ์ด์–ธํŠธ)์™€ ์›น ์„œ๋ฒ„ ์‚ฌ์ด์˜ ์•”ํ˜ธํ™”

1. ํ‚ค ๊ตํ™˜

- ์›น ๋ธŒ๋ผ์šฐ์ €๊ฐ€ AES ํ‚ค ์ƒ์„ฑ  ์›น ์„œ๋ฒ„์˜ ๊ณต๊ฐœ ํ‚ค๋กœ ์•”ํ˜ธํ™”  ์ธํ„ฐ๋„ท์œผ๋กœ ํŒจํ‚ท ์ „๋‹ฌ  ์›น ์„œ๋ฒ„์˜ private key๋กœ ๋ณตํ˜ธํ™”ํ•˜์—ฌ, ์„œ๋กœ์˜ ํ‚ค๋ฅผ ๊ณต์œ ํ•œ๋‹ค. (์˜ค๋ฒ„ํ—ค๋“œ๊ฐ€ ํฐ RSA ๋ฐฉ์‹์ด์ง€๋งŒ, ์ž‘์€ key ๊ฐ’์„ ์ฃผ๊ณ  ๋ฐ›์„ ๋•Œ ์‚ฌ์šฉ O)

2. ๋ฐ์ดํ„ฐ ๊ตํ™˜  ๋Œ€์šฉ๋Ÿ‰, AES ๋ฐฉ์‹

- ์•ž์„œ ๊ณต๊ฐœํ‚ค ๋ฐฉ์‹์œผ๋กœ shared ๋œ Key๋ฅผ ๊ณต์œ ํ•˜์—ฌ, ์•”ํ˜ธํ™”, ๋ณตํ˜ธํ™”๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›๋Š”๋‹ค. 

 

* Digital signature – ๋””์ง€ํ„ธ ์„œ๋ช… 

- for authentication & integrity (๋ณ€์กฐ๋˜์ง€ ์•Š์Œ!) // not confidentiality (๊ธฐ๋ฐ€์„ฑ๊ณผ ๋ฌด๊ด€)

- ex) ๊ณต์ธ ์ธ์ฆ์„œ์— private key๊ฐ€ ์ €์žฅ๋จ 

- ์›น ๋ธŒ๋ผ์šฐ์ €๊ฐ€ hash๋ฅผ ํ†ตํ•ด data ์–‘์„ ์ค„์ด๊ณ , ์ด๋ฅผ ์ž์‹ ์˜ private key๋กœ ์•”ํ˜ธํ™” ํ•œ ๋’ค, ์›๋ฌธ๊ณผ ํ•จ๊ป˜ ๋ณด๋ƒ„

- ์›น ์„œ๋ฒ„๋Š” ๋™์ผํ•œ hash ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ๊ณ„์‚ฐํ•œ ๊ฐ’์„, ๋ธŒ๋ผ์šฐ์ € ๊ณต๊ฐœํ‚ค๋กœ ๋ณตํ˜ธํ™” ํ•œ ๊ฐ’๊ณผ ๋น„๊ต 

-> ์„œ๋กœ ๊ฐ™์œผ๋ฉด ๋ณ€์กฐ๋˜์ง€ ์•Š์Œ ํ™•์ธ, ์„œ๋กœ ๋‹ค๋ฅด๋ฉด ์›๋ฌธ์ด ๋ณ€์กฐ๋จ์„ ์•Œ ์ˆ˜ ์žˆ์Œ 

 

*VPN - Virtual Private Network 

- ์„ค์บ  ๊ตญ์บ  ์‚ฌ์ด์˜ ์ „์šฉ์„   ๋น„์šฉ์ด ๋น„์‹ธ๋‹ค  ์ค‘๊ฐ„์— public internet์„ ํƒ€์•ผ ํ•จ 
–> 
์ด๋ฅผ software๋กœ virtualํ•˜๊ฒŒ private ์•”ํ˜ธํ™”

- ์•”ํ˜ธํ™” ํ•œ ํŠธ๋ž˜ํ”ฝ์€ ์ค‘๊ฐ„์— ๋ณผ ์ˆ˜ ์—†๋‹ค  ๋ณตํ˜ธํ™” ํ•˜์—ฌ ์›๋ฌธ์„ ์ „๋‹ฌ๋ฐ›์„ ์ˆ˜ ์žˆ์Œ