- ์ด์์ฒด์ = ์์๊ด๋ฆฌ์
- ํ์ ์ด์์ฒด์ : ์ปค๋
- ๊ด์ ์ด์์ฒด์ : ์ปค๋๋ฟ ์๋๋ผ ์ฃผ๋ณ ์์คํ ์ ํธ๋ฆฌํฐ ํฌํจ
- ์์๊ด๋ฆฌ์
- ๋จ์ผ ์ฌ์ฉ์ - MS-DOS
- ๋ค์ค ์ฌ์ฉ์ - UNIX,NT Server
- Realtime OS ์ ํด์ง ์๊ฐ ์์ ์ด๋ ํ ์ผ์ด ๋ฐ๋์ ์ข ๋ฃ๋จ์ด ๋ณด์ฅ๋์ด์ผํ๋ ์ค์๊ฐ ์์คํ ์ ์ํ OS
- ์์๋ก/๊ณต์ฅ ์ ์ด, ๋ฏธ์ฌ์ผ ์ ์ด, ๋ฐ๋์ฒด ์ฅ๋น
- ์ปดํจํฐ ์ฒ๋ฆฌ๋ฅ๋ ฅ์ ์ผ์ ํ ์๊ฐ๋จ์๋ก ๋ถํ ํด์ ์ฌ์ฉ
- ์ผ๊ด์ฒ๋ฆฌ ์์คํ ์ ๋นํด ์งง์ ์๋ต ์๊ฐ์ ๊ฐ์ง
- ์) Unix
- interactiveํ ๋ฐฉ์
- ์์ ์์ฒญ์ ์ผ์ ๋์ ๋ชจ์์ ํ๋ฒ์ ์ฒ๋ฆฌ
- ์์ ์ด ์ข ๋ฃ๋ ๋๊น์ง ๋๊ธฐ
- ์) ์ด๊ธฐ Punch Card ์ฒ๋ฆฌ ์์คํ
-
Multitasking
-
Multiprogramming
-
Time sharing
-
Multiprocess
-
๊ตฌ๋ถ
- ์์ ์ฉ์ด๋ค์ ์ปดํจํฐ์์ ์ฌ๋ฌ ์์ ์ ๋์์ ์ํํ๋ ๊ฒ์ ๋ปํ๋ค.
- Multiprogramming์ ์ฌ๋ฌ ํ๋ก๊ทธ๋จ์ด ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ผ๊ฐ ์์์ ๊ฐ์กฐ
- Time Sharing์ CPU์ ์๊ฐ์ ๋ถํ ํ์ฌ ๋๋์ด ์ด๋ค๋ ์๋ฏธ๋ฅผ ๊ฐ์กฐ
- Multiprocessor : ํ๋์ ์ปดํจํฐ์ CPU (processor)๊ฐ ์ฌ๋ฌ ๊ฐ ๋ถ์ด ์์์ ์๋ฏธ
- ์ฝ๋์ ๋๋ถ๋ถ์ C์ธ์ด๋ก ์์ฑ
- ๋์ ์ด์์ฑ
- ์ต์ํ์ ์ปค๋ ๊ตฌ์กฐ
- ๋ณต์กํ ์์คํ ์ ๋ง๊ฒ ํ์ฅ ์ฉ์ด
- ์์ค ์ฝ๋ ๊ณต๊ฐ
- ํ๋ก๊ทธ๋จ ๊ฐ๋ฐ์ ์ฉ์ด
- ๋ค์ํ ๋ฒ์
- System V, FreeBSD, SunOS, Solaris
- Linux
- MS์ฌ์์ 1981๋ IBM-PC๋ฅผ ์ํด ๊ฐ๋ฐ
- ๋จ์ผ ์ฌ์ฉ์์ฉ ์ด์์ฒด์ , ๋ฉ๋ชจ๋ฆฌ๊ด๋ฆฌ ๋ฅ๋ ฅ์ ํ๊ณ(์ฃผ ๊ธฐ์ต์ฅ์น : 640KB)
- MS์ฌ์ ๋ค์ค ์์ ์ฉ GUI ๊ธฐ๋ฐ ์ด์์ฒด์
- Plug and Play, ๋คํธ์ํฌ ํ๊ฒฝ ๊ฐํ
- DOS์ฉ ์์ฉ ํ๋ก๊ทธ๋จ๊ณผ ํธํ์ฑ ์ ๊ณต
- ๋ถ์์ ์ฑ
- ํ๋ถํ ์ง์ ์ํํธ์จ์ด
- PalmOS, Pocket PC(WinCE), Tiny OS
์ ์ถ๋ ฅ ๊ด๋ฆฌ : ๊ฐ๊ธฐ ๋ค๋ฅธ ์ ์ถ๋ ฅ์ฅ์น์ ์ปดํจํฐ ๊ฐ์ ์ด๋ป๊ฒ ์ ๋ณด๋ฅผ ์ฃผ๊ณ ๋ฐ๊ฒ ํ์ง ?
ํ๋ก์ธ์ค๊ด๋ฆฌ : 1. ํ๋ก์ธ์ค์ ์์ฑ๊ณผ ์ญ์ , 2. ์์ ํ ๋น ๋ฐ ๋ฐํ, 3. ํ๋ก์ธ์ค ๊ฐ ํ๋ ฅ
- ๋ณดํธ ์์คํ
- ๋คํธ์ํน
- ๋ช ๋ น์ด ํด์๊ธฐ (command line interpreter)
๋ณธ ๊ณผ๋ชฉ์ OS ์ฌ์ฉ์ ๊ด์ ์ด ์๋๋ผ OS ๊ฐ๋ฐ์ ๊ด์ ์์ ์๊ฐํด์ผํจ
๋๋ถ๋ถ์ ์๊ณ ๋ฆฌ์ฆ์ OS ํ๋ก๊ทธ๋จ ์์ฒด์ ๋ด์ฉ
์ธ๊ฐ์ ์ ์ฒด๊ฐ ๋์ ํต์ ๋ฅผ ๋ฐ๋ฏ ์ปดํจํฐ ํ๋์จ์ด๋ ์ด์์ฒด์ ์ ํต์ ๋ฅผ ๋ฐ์ผ๋ฉฐ ๊ทธ ์ด์์ฒด์ ๋ ์ฌ๋์ด ํ๋ก๊ทธ๋๋ฐํ๋ ๊ฒ์ด๋ค.
- CPU : mode bit, Interrupt line, registers
- DMA controller
- timer
- memory controller - Memory
- device controller - local buffer - disk, i/o divice
-
์ฌ์ฉ์ ํ๋ก๊ทธ๋จ์ ์๋ชป๋ ์ํ์ผ๋ก ๋ค๋ฅธ ํ๋ก๊ทธ๋จ ๋ฐ ์ด์์ฒด์ ์ ํผํด๊ฐ ๊ฐ์ง ์๋๋ก ํ๊ธฐ ์ํ ๋ณดํธ ์ฅ์น ํ์
-
Mode bit์ ํตํด ํ๋์จ์ด์ ์ผ๋ก ๋ ๊ฐ์ง ๋ชจ๋์ operation ์ง์
- 1 ์ฌ์ฉ์ ๋ชจ๋ : ์ฌ์ฉ์ ํ๋ก๊ทธ๋จ ์ํ
- 0 ๋ชจ๋ํฐ๋ชจ๋(์ปค๋ ๋ชจ๋, ์์คํ ๋ชจ๋)* : OS ์ฝ๋ ์ํ
- ๋ณด์์ ํด์น ์ ์๋ ์ค์ํ ๋ช ๋ น์ด๋ ๋ชจ๋ํฐ ๋ชจ๋์์๋ง ์ํ ๊ฐ๋ฅํ "ํน๊ถ๋ช ๋ น"์ผ๋ก ๊ท์
- Interrupt๋ Exception ๋ฐ์์ ํ๋์จ์ด๊ฐ mode bit์ 0์ผ๋ก ๋ฐ๊ฟ
- ์ฌ์ฉ์ ํ๋ก๊ทธ๋จ์๊ฒ CPU๋ฅผ ๋๊ธฐ๊ธฐ ์ ์ mode bit์ 1๋ก ์ ํ
-
์ ํด์ง ์๊ฐ์ด ํ๋ฅธ ๋ค ์ด์์ฒด์ ์๊ฒ ์ ์ด๊ถ์ด ๋์ด๊ฐ๋๋ก ์ธํฐ๋ฝํธ๋ฅผ ๋ฐ์์ํด
-
ํ์ด๋จธ๋ ๋งค ํด๋ญ ํฑ ๋๋ง๋ค 1์ฉ ๊ฐ์
-
ํ์ด๋จธ ๊ฐ์ด 0์ด ๋๋ฉด ํ์ด๋จธ ์ธํฐ๋ฝํธ ๋ฐ์
-
CPU๋ฅผ ํน์ ํ๋ก๊ทธ๋จ์ด ๋ ์ ํ๋ ๊ฒ์ผ๋ก๋ถํฐ ๋ณดํธ
-
ํ์ด๋จธ๋ time sharing์ ๊ตฌํํ๊ธฐ ์ํด ๋๋ฆฌ ์ด์ฉ๋จ
-
ํ์ด๋จธ๋ ํ์ฌ ์๊ฐ์ ๊ณ์ฐํ๊ธฐ ์ํด์๋ ์ฌ์ฉ
- I/O device controller
- ํด๋น I/O ์ฅ์น์ ํ์ ๊ด๋ฆฌํ๋ ์ผ์ข ์ ์์ CPU
- ์ ์ด ์ ๋ณด๋ฅผ ์ํด control register, status register๋ฅผ ๊ฐ์ง
- local buffer๋ฅผ ๊ฐ์ง(์ผ์ข ์ data register)
- I/O๋ ์ค์ device์ local buffer ์ฌ์ด์์ ์ผ์ด๋จ
- Device controller๋ I/O๊ฐ ๋๋ฌ์ ๊ฒฝ์ฐ interrupt๋ก CPU์ ๊ทธ ์ฌ์ค์ ์๋ฆผ
- device driver(์ฅ์น ๊ตฌ๋๊ธฐ) : OS ์ฝ๋ ์ค ๊ฐ ์ฅ์น๋ณ ์ฒ๋ฆฌ ๋ฃจํด >> software
- device controller(์ฅ์น์ ์ด๊ธฐ) : ๊ฐ ์ฅ์น๋ฅผ ํต์ ํ๋ ์ผ์ข ์ ์์ CPU >> hardware
- ๋ชจ๋ ์ ์ถ๋ ฅ ๋ช ๋ น์ ํน๊ถ ๋ช ๋ น
- ์ฌ์ฉ์ ํ๋ก๊ทธ๋จ์ ์ด๋ป๊ฒ I/O๋ฅผ ํ๋๊ฐ ?
- ์์คํ ์ฝ : ์ฌ์ฉ์ ํ๋ก๊ทธ๋จ์ ์ด์์ฒด์ ์๊ฒ I/O ์์ฒญ
- trap์ ์ฌ์ฉํ์ฌ ์ธํฐ๋ฝํธ ๋ฒกํฐ์ ํน์ ์์น๋ก ์ด๋
- ์ ์ด๊ถ์ด ์ธํฐ๋ฝํธ ๋ฒกํฐ๊ฐ ๊ฐ๋ฆฌํค๋ ์ธํฐ๋ฝํธ ์๋น์ค ๋ฃจํด์ผ๋ก ์ด๋
- ์ฌ๋ฐ๋ฅธ I/O ์์ฒญ์ธ์ง ํ์ธ ํ I/O ์ํ
- I/O ์๋ฃ ์ ์ ์ด๊ถ์ ์์คํ ์ฝ ๋ค์ ๋ช ๋ น์ผ๋ก ์ฎ๊น
-
์ธํฐ๋ฝํธ : ์ธํฐ๋ฝํธ ๋นํ ์์ ์ ๋ ์ง์คํฐ์ program counter๋ฅผ saveํ ํ CPU์ ์ ์ด๋ฅผ ์ธํฐ๋ฝํธ ์ฒ๋ฆฌ ๋ฃจํด์ ๋๊ธด๋ค.
-
Interrupt(๋์์๋ฏธ)
-
Interrupt(ํ๋์จ์ด ์ธํฐ๋ฝํธ) : ํ๋์จ์ด๊ฐ ๋ฐ์์ํจ ์ธํฐ๋ฝํธ
-
Trap(์ํํธ์จ์ด ์ธํฐ๋ฝํธ) : Exception(ํ๋ก๊ทธ๋จ์ด ์ค๋ฅ๋ฅผ ๋ฒํ ๊ฒฝ์ฐ), System call(ํ๋ก๊ทธ๋จ์ด ์ปค๋ ํจ์๋ฅผ ํธ์ถํ๋ ๊ฒฝ์ฐ)
-
์ธํฐ๋ฝํธ ๊ด๋ จ ์ฉ์ด
-
์ธํฐ๋ฝํธ ๋ฒกํฐ : ํด๋น ์ธํฐ๋ฝํธ์ ์ฒ๋ฆฌ ๋ฃจํด ์ฃผ์๋ฅผ ๊ฐ์ง๊ณ ์์
-
์ธํฐ๋ฝํธ ์ฒ๋ฆฌ ๋ฃจํด (Interrupt Service Routine, ์ธํฐ๋ฝํธ ํธ๋ค๋ฌ), ํด๋น ์ธํฐ๋ฝํธ๋ฅผ ์ฒ๋ฆฌํ๋ ์ปค๋ ํจ์
- ํ๋์ ์ด์์ฒด์ ๋ ์ธํฐ๋ฝํธ์ ์ํด ๊ตฌ๋๋จ
- ์์คํ ์ฝ
- ์ฌ์ฉ์ ํ๋ก๊ทธ๋จ์ด ์ด์์ฒด์ ์ ์๋น์ค๋ฅผ ๋ฐ๊ธฐ ์ํด ์ปค๋ ํจ์๋ฅผ ํธ์ถํ๋ ๊ฒ
-
๋๊ธฐ์ ์ ์ถ๋ ฅ(synchronous I/O)
-
I/O ์์ฒญ ํ ์ ์ถ๋ ฅ ์์ ์ด ์๋ฃ๋ ํ์์ผ ์ ์ด๊ฐ ์ฌ์ฉ์ ํ๋ก๊ทธ๋จ์ ๋์ด๊ฐ
-
๊ตฌํ๋ฐฉ๋ฒ 1
- I/O๊ฐ ๋๋ ๋๊น์ง CPU๋ฅผ ๋ญ๋น์ํด
- ๋งค์์ ํ๋์ I/O๋ง ์ผ์ด๋ ์ ์์
-
๊ตฌํ๋ฐฉ๋ฒ 2
- I/O๊ฐ ์๋ฃ๋ ๋๊น์ง ํด๋น ํ๋ก๊ทธ๋จ์๊ฒ์ CPU๋ฅผ ๋นผ์์
- I/O ์ฒ๋ฆฌ๋ฅผ ๊ธฐ๋ค๋ฆฌ๋ ์ค์ ๊ทธ ํ๋ก๊ทธ๋จ์ ์ค ์ธ์
- ๋ค๋ฅธ ํ๋ก๊ทธ๋จ์๊ฒ CPU๋ฅผ ์ค
-
-
๋น๋๊ธฐ์ ์ ์ถ๋ ฅ (asynchoronous I/O)
- I/O๊ฐ ์์๋ ํ ์ ์ถ๋ ฅ ์์ ์ด ๋๋๊ธฐ๋ฅผ ๊ธฐ๋ค๋ฆฌ์ง ์๊ณ ์ ์ด๊ฐ ์ฌ์ฉ์ ํ๋ก๊ทธ๋จ์ ์ฆ์ ๋์ด๊ฐ
-
๋ ๊ฒฝ์ฐ ๋ชจ๋ I/O์ ์๋ฃ๋ ์ธํฐ๋ฝํธ๋ก ์๋ ค์ค
- ๋น ๋ฅธ ์ ์ถ๋ ฅ ์ฅ์น๋ฅผ ๋ฉ๋ชจ๋ฆฌ์ ๊ฐ๊น์ด ์๋๋ก ์ฒ๋ฆฌํ๊ธฐ ์ํด ์ฌ์ฉ
- CPU์ ์ค์ฌ ์์ด device controller๊ฐ device์ buffer storage์ ๋ด์ฉ์ ๋ฉ๋ชจ๋ฆฌ์ block ๋จ์๋ก ์ง์ ์ ์ก
- ๋ฐ์ดํธ ๋จ์๊ฐ ์๋๋ผ block ๋จ์๋ก ์ธํฐ๋ฝํธ๋ฅผ ๋ฐ์์ํด
- I/O๋ฅผ ์ํํ๋ special instruction์ ์ํด
- Memory Mapped I/O์ ์ํด
Primary : Registers > Cache Memory > Main Memory
Secondary : Magnetic Disk > Optical Disk
Registers > Cache Memory > Main Memory > Magnetic Disk > Optical Disk
- code : ์ปค๋์ฝ๋
- ์์คํ ์ฝ, ์ธํฐ๋ฝํธ ์ฒ๋ฆฌ ์ฝ๋
- ์์๊ด๋ฆฌ๋ฅผ ์ํ ์ฝ๋
- ํธ๋ฆฌํ ์๋น์ค ์ ๊ณต์ ์ํ ์ฝ๋
- data :
- PCB-ProcessA, ProcessB
- CPU
- mem
- disk
- stack
- Process A์ ์ปค๋ ์คํ
- Process B์ ์ปค๋ ์คํ
-
ํจ์
-
์ฌ์ฉ์ ์ ์ ํจ์ >> ํ๋ก์ธ์คA์ Address space(code, data, stack)
- ์์ ์ ํ๋ก๊ทธ๋จ์์ ์ ์ํ ํจ์
-
๋ผ์ด๋ธ๋ฌ๋ฆฌ ํจ์ >> ํ๋ก์ธ์คA์ Address space(code, data, stack)
- ์์ ์ ํ๋ก๊ทธ๋จ์์ ์ ์ํ์ง ์๊ณ ๊ฐ๋ค ์ด ํจ์
- ์์ ์ ํ๋ก๊ทธ๋จ์ ์คํ ํ์ผ์ ํฌํจ๋์ด ์๋ค.
-
์ปค๋ ํจ์ >> Kernel Address space(code, data, stack)
- ์ด์์ฒด์ ํ๋ก๊ทธ๋จ์ ํจ์
- ์ปค๋ ํจ์์ ํธ์ถ = ์์คํ ์ฝ
-
- program begins
- A์ ์ฃผ์๊ณต๊ฐ : user mode > user defined function call
- Kernel์ ์ฃผ์๊ณต๊ฐ : kernel mode > system call > return from kernel
- A์ ์ฃผ์๊ณต๊ฐ : user mode > library function call
- Kernel์ ์ฃผ์๊ณต๊ฐ : kernel mode > system call
- program ends
-
"Process is a program in execution"
-
ํ๋ก์ธ์ค์ ๋ฌธ๋งฅ(context)
- CPU ์ํ ์ํ๋ฅผ ๋ํ๋ด๋ ํ๋์จ์ด ๋ฌธ๋งฅ
- Program Counter
- ๊ฐ์ข register
- ํ๋ก์ธ์ค์ ์ฃผ์ ๊ณต๊ฐ
- code, data, stack
- ํ๋ก์ธ์ค ๊ด๋ จ ์ปค๋ ์๋ฃ ๊ตฌ์กฐ
- PCB (Process Control Block)
- Kernel stack
- CPU ์ํ ์ํ๋ฅผ ๋ํ๋ด๋ ํ๋์จ์ด ๋ฌธ๋งฅ
-
Running
- CPU๋ฅผ ์ก๊ณ instruction์ ์ํ์ค์ธ ์ํ
-
Ready
- CPU๋ฅผ ๊ธฐ๋ค๋ฆฌ๋ ์ํ(๋ฉ๋ชจ๋ฆฌ ๋ฑ ๋ค๋ฅธ ์กฐ๊ฑด์ ๋ชจ๋ ๋ง์กฑํ๊ณ )
-
Blocked(wait, sleep)
- CPU๋ฅผ ์ฃผ์ด๋ ๋น์ฅ instruction์ ์ํํ ์ ์๋ ์ํ
- Process ์์ ์ด ์์ฒญํ event(์ : I/O)๊ฐ ์ฆ์ ๋ง์กฑ๋์ง ์์ ์ด๋ฅผ ๊ธฐ๋ค๋ฆฌ๋ ์ํ
- I/O๋ฑ์ event๋ฅผ ์ค์ค๋ก ๊ธฐ๋ค๋ฆฌ๋ ์ํ
- (์) ๋์คํฌ์์ file์ ์ฝ์ด์์ผ ํ๋ ๊ฒฝ์ฐ
-
Suspended (stopped)
- ์ธ๋ถ์ ์ธ ์ด์ ๋ก ํ๋ก์ธ์ค์ ์ํ์ด ์ ์ง๋ ์ํ
- ํ๋ก์ธ์ค๋ ํต์งธ๋ก ๋์คํฌ์ swap out๋๋ค.
- (์) ์ฌ์ฉ์๊ฐ ํ๋ก๊ทธ๋จ์ ์ผ์ ์ ์ง์ํจ ๊ฒฝ์ฐ (break key) ์์คํ ์ด ์ฌ๋ฌ ์ด์ ๋ก ํ๋ก์ธ์ค๋ฅผ ์ ์ ์ค๋จ์ํด (๋ฉ๋ชจ๋ฆฌ์ ๋๋ฌด ๋ง์ ํ๋ก์ธ์ค๊ฐ ์ฌ๋ผ์ ์์ ๋)
-
New : ํ๋ก์ธ์ค๊ฐ ์์ฑ์ค์ธ ์ํ
-
Terminated : ์ํ(execution)์ด ๋๋ ์ํ
-
Blocked : ์์ ์ด ์์ฒญํ event๊ฐ ๋ง์กฑ๋๋ฉด Ready
-
Suspended : ์ธ๋ถ์์ resume ํด์ฃผ์ด์ผ Active
- ์ด์์ฒด์ ๊ฐ ๊ฐ ํ๋ก์ธ์ค๋ฅผ ๊ด๋ฆฌํ๊ธฐ ์ํด ํ๋ก์ธ์ค๋น ์ ์งํ๋ ์ ๋ณด
- ๋ค์์ ๊ตฌ์ฑ ์์๋ฅผ ๊ฐ์ง๋ค. (๊ตฌ์กฐ์ฒด๋ก ์ ์ง)
- (1) OS๊ฐ ๊ด๋ฆฌ์ ์ฌ์ฉํ๋ ์ ๋ณด
- Process state, Process ID
- scheduling information, priority
- (2) CPU ์ํ ๊ด๋ จ ํ๋์จ์ด ๊ฐ
- Program counter, register
- (3) ๋ฉ๋ชจ๋ฆฌ ๊ด๋ จ
- Code, data, stack์ ์์น ์ ๋ณด
- (4) ํ์ผ ๊ด๋ จ
- Open file descriptors..
- (1) OS๊ฐ ๊ด๋ฆฌ์ ์ฌ์ฉํ๋ ์ ๋ณด
- CPU๋ฅผ ํ ํ๋ก์ธ์ค์์ ๋ค๋ฅธ ํ๋ก์ธ์ค๋ก ๋๊ฒจ์ฃผ๋ ๊ณผ์
- CPU๊ฐ ๋ค๋ฅธ ํ๋ก์ธ์ค์๊ฒ ๋์ด๊ฐ ๋ ์ด์์ฒด์ ๋ ๋ค์์ ์ํ
- CPU๋ฅผ ๋ด์ด์ฃผ๋ ํ๋ก์ธ์ค์ ์ํ๋ฅผ ๊ทธ ํ๋ก์ธ์ค์ PCB์ ์ ์ฅ
- CPU๋ฅผ ์๋กญ๊ฒ ์ป๋ ํ๋ก์ธ์ค์ ์ํ๋ฅผ PCB์์ ์ฝ์ด์ด
- System call์ด๋ interrupt ๋ฐ์์ ๋ฐ๋์ context switch๊ฐ ์ผ์ด๋๋ ๊ฒ์ ์๋
-
A case
-
- ์ฌ์ฉ์ ํ๋ก์ธ์ค A(user mode)
-
- interrupt or system call
-
- ISR or system call ํจ์(kernel mode)
-
- ๋ฌธ๋งฅ๊ตํ ์์ด user mode ๋ณต๊ท
-
- ์ฌ์ฉ์ ํ๋ก์ธ์ค A
-
-
B case
-
- ์ฌ์ฉ์ ํ๋ก์ธ์ค A(user mode)
-
- timer interrupt or I/O ์์ฒญ system call
-
- kernel mode
-
- ๋ฌธ๋งฅ๊ตํ ์ผ์ด๋จ
-
- ์ฌ์ฉ์ ํ๋ก์ธ์ค B(user mode)
-
- Job queue
- ํ์ฌ ์์คํ ๋ด์ ์๋ ๋ชจ๋ ํ๋ก์ธ์ค์ ์งํฉ
- Ready queue
- ํ์ฌ ๋ฉ๋ชจ๋ฆฌ ๋ด์ ์์ผ๋ฉด์ CPU๋ฅผ ์ก์์ ์คํ๋๊ธฐ๋ฅผ ๊ธฐ๋ค๋ฆฌ๋ ํ๋ก์ธ์ค์ ์งํฉ
- Device queues
- I/O device์ ์ฒ๋ฆฌ๋ฅผ ๊ธฐ๋ค๋ฆฌ๋ ํ๋ก์ธ์ค์ ์งํฉ
- ํ๋ก์ธ์ค๋ค์ ๊ฐ ํ๋ค์ ์ค๊ฐ๋ฉฐ ์ํ๋๋ค.
-
Long-term scheduler (์ฅ๊ธฐ ์ค์ผ์ค๋ฌ or job scheduler)
- ์์ ํ๋ก์ธ์ค ์ค ์ด๋ค ๊ฒ๋ค์ ready queue๋ก ๋ณด๋ผ์ง ๊ฒฐ์
- ํ๋ก์ธ์ค์ memory(๋ฐ ๊ฐ์ข ์์)์ ์ฃผ๋ ๋ฌธ์
- degree of Multiprogramming์ ์ ์ด
- time sharing system์๋ ๋ณดํต ์ฅ๊ธฐ ์ค์ผ์ค๋ฌ๊ฐ ์์ (๋ฌด์กฐ๊ฑด ready)
-
Short-term scheduler(๋จ๊ธฐ ์ค์ผ์ค๋ฌ or CPU scheduler)
- ์ด๋ค ํ๋ก์ธ์ค๋ฅผ ๋ค์๋ฒ์ running์ํฌ์ง ๊ฒฐ์
- ํ๋ก์ธ์ค์ CPU๋ฅผ ์ฃผ๋ ๋ฌธ์
- ์ถฉ๋ถํ ๋นจ๋ผ์ผ ํจ(millisecond ๋จ์)
-
Medium-Term Scheduler(์ค๊ธฐ ์ค์ผ์ค๋ฌ or Swapper)
- ์ฌ์ ๊ณต๊ฐ ๋ง๋ จ์ ์ํด ํ๋ก์ธ์ค๋ฅผ ํต์งธ๋ก ๋ฉ๋ชจ๋ฆฌ์์ ๋์คํฌ๋ก ์ซ์๋
- ํ๋ก์ธ์ค์๊ฒ์ memory๋ฅผ ๋บ๋ ๋ฌธ์
- degree of Multiprogramming์ ์ ์ด
-
"A thread (or lightweight process) is basic unit of CPU utilization"
-
Thread์ ๊ตฌ์ฑ
- program counter
- register set
- stack space
-
Thread๊ฐ ๋๋ฃ thread์ ๊ณต์ ํ๋ ๋ถ๋ถ(=task)
- code section
- data section
- OS resources
-
์ ํต์ ์ธ ๊ฐ๋ ์ heavyweight process๋ ํ๋์ thread๋ฅผ ๊ฐ์ง๊ณ ์๋ task๋ก ๋ณผ ์ ์๋ค.
-
ํ๋ก์ธ์ค ์ฃผ์๊ณต๊ฐ : Stack : (Thread1์ Stack, Thread2์ Stack, Thread3์ Stack), data, code
-
์ด์์ฒด์ ๋ด๋ถ์ ํ๋ก์ธ์ค ํ๋๋ฅผ ๊ด๋ฆฌํ๊ธฐ ์ํด PCB๋ฅผ ๊ฐ์ง๊ณ ์๋ค.
-
PCB (pointer, process state, process number, program counter, registers, memory limits, list of open files....)
-
ํ๋ก์ธ์ค๋ ํ๋๋ง ๋์๋๊ณ (code, data, stack) CPU๊ฐ ์ฝ๋์ ์ด๋ ๋ถ๋ถ์ ์คํํ๊ณ ์๋๊ฐ(ํ๋ก๊ทธ๋จ ์นด์ดํฐ) ์ฆ, ํ๋ก๊ทธ๋จ ์นด์ดํฐ๋ง ์ฌ๋ฌ ๊ฐ๋ฅผ ๋๋ ๊ฒ, ํ๋ก์ธ์ค ํ๋์ CPU ์ํ๋จ์๋ง ์ฌ๋ฌ๊ฐ๋ฅผ ๋๋ ๊ฒ์ "Thread, ์ค๋ ๋"๋ผ๊ณ ํ๋ค.
-
์ค๋ ๋๋ ํ๋ก์ธ์ค ํ๋์์ ๊ณต์ ํ ์ ์๋ ๊ฒ์ ์ต๋ํ ๊ณต์ ํ๊ณ (๋ฉ๋ชจ๋ฆฌ๋ฅผ ๊ณต์ ํ๊ณ , ํ๋ก์ธ์ค ์ํ๋ ๊ณต์ ํจ)
-
์ค๋ ๋๋ ์คํ๊ณผ ํ๋ก๊ทธ๋จ ์นด์ดํฐ๋ง ๋ณ๋๋ก ๊ฐ์ง๊ณ ์๋ค.
- ๋ค์ค ์ค๋ ๋๋ก ๊ตฌ์ฑ๋ ํ์คํฌ ๊ตฌ์กฐ์์๋ ํ๋์ ์๋ฒ ์ค๋ ๋๊ฐ blocked (waiting) ์ํ์ธ ๋์์๋ ๋์ผํ ํ์คํฌ ๋ด์ ๋ค๋ฅธ ์ค๋ ๋๊ฐ ์คํ(running)๋์ด ๋น ๋ฅธ ์ฒ๋ฆฌ๋ฅผ ํ ์ ์๋ค.
- ๋์ผํ ์ผ์ ์ํํ๋ ๋ค์ค ์ค๋ ๋๊ฐ ํ๋ ฅํ์ฌ ๋์ ์ฒ๋ฆฌ์จ(throughput)๊ณผ ์ฑ๋ฅ ํฅ์์ ์ป์ ์ ์๋ค.
- ์ค๋ ๋๋ฅผ ์ฌ์ฉํ๋ฉด ๋ณ๋ ฌ์ฑ์ ๋์ผ ์ ์๋ค.
- ๋น ๋ฅธ ์๋ต์ฑ์ ๊ฐ์ง ์ ์๋ค, ์์์ ์ฝ์ฑ์ ๊ฐ์ง ์ ์๋ค.
- Responsiveness
- eg) multi-threaded Web - if one thread is blocked (eg network), anther thread continues (eg display)
- Resource Sharing
- n threads can share binary code, data, resource of the process
- Econnomy
- creating & CPU switching thread (rather than a process)
- Solaris์ ๊ฒฝ์ฐ ์ ๋ ๊ฐ์ง์ ๋ํด ํ๋ก์ธ์ค์ overhead๊ฐ ๊ฐ๊ฐ 30๋ฐฐ, 5๋ฐฐ
- Utilization of MP(๋ฉํฐํ๋ก์ธ์) Architectures
- each thread may be running in parrel on a different processor
- ์ ์ฒด KB(Process, heavyweight)
PCB
{
pointer, >> OS ๊ด๋ฆฌ์ฉ ์ ๋ณด
process state, >> OS ๊ด๋ฆฌ์ฉ ์ ๋ณด
process number, >> OS ๊ด๋ฆฌ์ฉ ์ ๋ณด
<br>
program counter, >> CPU ๊ด๋ จ ์ ๋ณด(์ words)
registers >> Thread, lightweight
memory limits >> ์์ ๊ด๋ จ ์ ๋ณด
list of open files >> ์์ ๊ด๋ จ ์ ๋ณด
}
-
Some are supported by kernel >> Kernel Threads
- Windows 95/98/NT
- Solaris
- Digital UNIX, Mach
-
Others are supported by library >> User Threads
- POSIX Pthreads
- Mach C-threads
- Solaris threads
-
Some are real-time threads
Copy-on-write (CoW)
-
๋ถ๋ชจ ํ๋ก์ธ์ค(Parent process)๊ฐ ์์ ํ๋ก์ธ์ค(children process) ์์ฑ
-
ํ๋ก์ธ์ค์ ํธ๋ฆฌ(๊ณ์ธต ๊ตฌ์กฐ)ํ์ฑ
-
ํ๋ก์ธ์ค๋ ์์์ ํ์๋ก ํจ
- ์ด์์ฒด์ ๋ก๋ถํฐ ๋ฐ๋๋ค.
- ๋ถ๋ชจ์ ๊ณต์ ํ๋ค.
-
์์์ ๊ณต์
- ๋ถ๋ชจ์ ์์์ด ๋ชจ๋ ์์์ ๊ณต์ ํ๋ ๋ชจ๋ธ
- ์ผ๋ถ๋ฅผ ๊ณต์ ํ๋ ๋ชจ๋ธ
- ์ ํ ๊ณต์ ํ์ง ์๋ ๋ชจ๋ธ
-
์ํ(Execution)
- ๋ถ๋ชจ์ ์์์ ๊ณต์กดํ๋ฉฐ ์ํ๋๋ ๋ชจ๋ธ
- ์์์ด ์ข ๋ฃ(terminate)๋ ๋๊น์ง ๋ถ๋ชจ๊ฐ ๊ธฐ๋ค๋ฆฌ๋(wait) ๋ชจ๋ธ
-
์ฃผ์๊ณต๊ฐ (Address space)
- ์์์ ๋ถ๋ชจ์ ๊ณต๊ฐ์ ๋ณต์ฌํจ(binary and OS data)
- ์์์ ๊ทธ ๊ณต๊ฐ์ ์๋ก์ด ํ๋ก๊ทธ๋จ์ ์ฌ๋ฆผ
- ์ ๋์ค์ ์
- fork() ์์คํ
์ฝ(์ด์์ฒด์ ํํ
๋ถํํด์ ์์ฑ๋๋ ๊ฒ)์ด ์๋ก์ด ํ๋ก์ธ์ค๋ฅผ ์์ฑ
- ๋ถ๋ชจ๋ฅผ ๊ทธ๋๋ก ๋ณต์ฌ (OS data except PID + binary)
- ์ฃผ์๊ณต๊ฐ ํ ๋น
- fork ๋ค์์ ์ด์ด์ง๋ exec() ์์คํ ์ฝ์ ํตํด ์๋ก์ด ํ๋ก๊ทธ๋จ์ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฆผ
- fork() ์์คํ
์ฝ(์ด์์ฒด์ ํํ
๋ถํํด์ ์์ฑ๋๋ ๊ฒ)์ด ์๋ก์ด ํ๋ก์ธ์ค๋ฅผ ์์ฑ
- ํ๋ก์ธ์ค๊ฐ ๋ง์ง๋ง ๋ช
๋ น์ ์ํํ ํ ์ด์์ฒด์ ์๊ฒ ์ด๋ฅผ ์๋ ค์ค (exit)
- ์์์ด ๋ถ๋ชจ์๊ฒ output data๋ฅผ ๋ณด๋ (via wait)
- ํ๋ก์ธ์ค์ ๊ฐ์ข ์์๋ค์ด ์ด์์ฒด์ ์๊ฒ ๋ฐ๋ฉ๋จ
- ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ์์์ ์ํ์ ์ข
๋ฃ์ํด(abort)
- ์์์ด ํ ๋น ์์์ ํ๊ณ์น๋ฅผ ๋์ด์ฌ
- ์์์๊ฒ ํ ๋น๋ ํ์คํฌ๊ฐ ๋ ์ด์ ํ์ํ์ง ์์
- ๋ถ๋ชจ๊ฐ ์ข
๋ฃ(exit)ํ๋ ๊ฒฝ์ฐ
- ์ด์์ฒด์ ๋ ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ์ข ๋ฃํ๋ ๊ฒฝ์ฐ ์์์ด ๋ ์ด์ ์ํ๋๋๋ก ๋์ง ์๋๋ค.
- ๋จ๊ณ์ ์ธ ์ข ๋ฃ
-
A process is created by the fork() system call.
- creates a new address space that is a duplicate of the caller
int main() { int pid; pid = fork(); if (pid == 0) /* this is child*/ printf("\n Hello, I am child!\n"); else if (pid > 0) /* this is parent*/ printf("\n Hello, I am parent!\n") }
- A process can execute a different program by the exec() system call.
- replaces the memory image of the caller with a new program.
int main()
{
int pid;
pid = fork();
if (pid == 0) /* this is child */
{
printf("\n Hello, I am child! Now I'll run date\n");
execlp("/bin/date", "/bin/date", (char *)0);
}
else if (pid > 0) /* this is parent*/
printf("\n Hello, I am parent!\n");
}
int main()
{
printf("1");
execlp("echo", "echo", "3", (char *) 0); /* 1 , echo ์ถ๋ ฅ*/
printf("2");
}
- ํ๋ก์ธ์ค A๊ฐ wait() ์์คํ
์ฝ์ ํธ์ถํ๋ฉด
- ์ปค๋์ child๊ฐ ์ข ๋ฃ๋ ๋๊น์ง ํ๋ก์ธ์ค A๋ฅผ sleep ์ํจ๋ค. (block ์ํ)
- Child process๊ฐ ์ข ๋ฃ๋๋ฉด ์ปค๋์ ํ๋ก์ธ์ค A๋ฅผ ๊นจ์ด๋ค. (ready ์ํ)
main()
{
int childPID;
s1;
childPID = fork();
if(childPID == 0 )
<code for child process>
else {
wait();
}
s2;
}
-
ํ๋ก์ธ์ค์ ์ข ๋ฃ
-
์๋ฐ์ ์ข ๋ฃ
- ๋ง์ง๋ง statement ์ํ ํ exit() ์์คํ ์ฝ์ ํตํด
- ํ๋ก๊ทธ๋จ์ ๋ช ์์ ์ผ๋ก ์ ์ด์ฃผ์ง ์์๋ mainํจ์๊ฐ ๋ฆฌํด๋๋ ์์น์ ์ปดํ์ผ๋ฌ๊ฐ ๋ฃ์ด์ค
-
๋น์๋ฐ์ ์ข ๋ฃ(์ธ๋ถ์์ ์ข ๋ฃ์ํด, ๋ถ๋ชจํ๋ก์ธ์ค๋ ์ฌ๋์ด ์ข ๋ฃ ์ํด)
- ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ์์ ํ๋ก์ธ์ค๋ฅผ ๊ฐ์ ์ข
๋ฃ์ํด
- ์์ ํ๋ก์ธ์ค๊ฐ ํ๊ณ์น๋ฅผ ๋์ด์๋ ์์ ์์ฒญ
- ์์์๊ฒ ํ ๋น๋ ํ์คํฌ๊ฐ ๋ ์ด์ ํ์ํ์ง ์์
- ํค๋ณด๋๋ก kill, break ๋ฑ์ ์น ๊ฒฝ์ฐ
- ๋ถ๋ชจ๊ฐ ์ข
๋ฃํ๋ ๊ฒฝ์ฐ
- ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ์ข ๋ฃํ๊ธฐ ์ ์ ์์๋ค์ด ๋จผ์ ์ข ๋ฃ๋จ.
- ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ์์ ํ๋ก์ธ์ค๋ฅผ ๊ฐ์ ์ข
๋ฃ์ํด
-
-
fork() create a child(copy)
-
exec() overlay new image
-
wait() sleep until child is done
-
exit() frees all the resources, notify parent
-
๋ ๋ฆฝ์ ํ๋ก์ธ์ค(Independent process)
- ํ๋ก์ธ์ค๋ ๊ฐ์์ ์ฃผ์ ๊ณต๊ฐ์ ๊ฐ์ง๊ณ ์ํ๋๋ฏ๋ก ์์น์ ์ผ๋ก ํ๋์ ํ๋ก์ธ์ค๋ ๋ค๋ฅธ ํ๋ก์ธ์ค์ ์ํ์ ์ํฅ์ ๋ฏธ์น์ง ๋ชปํจ
-
ํ๋ ฅ ํ๋ก์ธ์ค(Cooperating process)
- ํ๋ก์ธ์ค ํ๋ ฅ ๋ฉ์ปค๋์ฆ์ ํตํด ํ๋์ ํ๋ก์ธ์ค๊ฐ ๋ค๋ฅธ ํ๋ก์ธ์ค์ ์ํ์ ์ํฅ์ ๋ฏธ์น ์ ์์
-
ํ๋ก์ธ์ค๊ฐ ํ๋ ฅ ๋ฉ์ปค๋์ฆ(IPC: Interprocess Communication)
-
๋ฉ์์ง๋ฅผ ์ ๋ฌํ๋ ๋ฐฉ๋ฒ
- message passing : ์ปค๋์ ํตํด ๋ฉ์์ง ์ ๋ฌ
-
์ฃผ์ ๊ณต๊ฐ์ ๊ณต์ ํ๋ ๋ฐฉ๋ฒ
-
shared memory : ์๋ก ๋ค๋ฅธ ํ๋ก์ธ์ค ๊ฐ์๋ ์ผ๋ถ ์ฃผ์๊ณต๊ฐ์ ๊ณต์ ํ๊ฒ ํ๋ shared memory ๋ฉ์ปค๋์ฆ์ด ์์
-
thread : thread๋ ์ฌ์ค์ ํ๋์ ํ๋ก์ธ์ค์ด๋ฏ๋ก ํ๋ก์ธ์ค ๊ฐ ํ๋ ฅ์ผ๋ก* ๋ณด๊ธฐ๋ ์ด๋ ต์ง๋ง ๋์ผํ ํ๋ก์ธ์ค๋ฅผ ๊ตฌ์ฑํ๋ thread๊ฐ์๋ ์ฃผ์๊ณต๊ฐ์ ๊ณต์ ํ๋ฏ๋ก ํ๋ ฅ์ด ๊ฐ๋ฅ
-
-
-
Message system
- ํ๋ก์ธ์ค ์ฌ์ด์ ๊ณต์ ๋ณ์(shared variable)๋ฅผ ์ผ์ฒด ์ฌ์ฉํ์ง ์๊ณ ํต์ ํ๋ ์์คํ
-
Direct Communication
- ํต์ ํ๋ ค๋ ํ๋ก์ธ์ค์ ์ด๋ฆ์ ๋ช ์์ ์ผ๋ก ํ์
- Process P >>>> Process Q Send (Q, message) Receive(P, message)
-
Indirect Communication
- mailbox (๋๋ port)๋ฅผ ํตํด ๋ฉ์์ง๋ฅผ ๊ฐ์ ์ ๋ฌ Process P >> Mailbox >> M Process Q Send (M, message) Receive(M, message)
CPU burst : load store, add store, read from file I/O burst : wait for I/O CPU burst : store increment, index, write to file I/O burst : wait for I/O CPU burst : load store, add store, read from file I/O burst : wait for I/O
- ์ฌ๋ฌ ์ข ๋ฅ์ job(=process)๊ฐ ์์ฌ ์๊ธฐ ๋๋ฌธ์ CPU ์ค์ผ์ค๋ง์ด ํ์ํ๋ค.
- interactive job์๊ฒ ์ ์ ํ response ์ ๊ณต ์๋ง
- CPU์ I/O ์ฅ์น ์์คํ ์์์ ๊ณจ๊ณ ๋ฃจ ํจ์จ์ ์ผ๋ก ์ฌ์ฉ
-
ํ๋ก์ธ์ค๋ ๊ทธ ํน์ฑ์ ๋ฐ๋ผ ๋ค์ ๋ ๊ฐ์ง๋ก ๋๋
-
I/O-bound process
- CPU๋ฅผ ์ก๊ณ ๊ณ์ฐํ๋ ์๊ฐ๋ณด๋ค I/O์ ๋ง์ ์๊ฐ์ด ํ์ํ job
- (many short CPU burst)
-
CPU-bound process
- ๊ณ์ฐ ์์ฃผ์ job
- few very long CPU bursts
-
-
CPU Scheduler (์ด์์ฒด์ ์ฝ๋, CPU ์ค ํ๋ก์ธ์ค๋ฅผ ๊ณ ๋ฆ)
- Ready ์ํ์ ํ๋ก์ธ์ค ์ค์์ ์ด๋ฒ์ CPU๋ฅผ ์ค ํ๋ก์ธ์ค๋ฅผ ๊ณ ๋ฅธ๋ค.
-
Dispatcher (์ด์์ฒด์ ์ฝ๋, ์ ํ๋ ํ๋ก์ธ์ค์๊ฒ ๋๊น)
- CPU์ ์ ์ด๊ถ์ CPU scheduler์ ์ํด ์ ํ๋ ํ๋ก์ธ์ค์๊ฒ ๋๊ธด๋ค.
- ์ด ๊ณผ์ ์ context switch(๋ฌธ๋งฅ ๊ตํ)์ด๋ผ๊ณ ํ๋ค.
- CPU ์ค์ผ์ค๋ง์ด ์ธ์ ํ์ํ๊ฐ ? (๋ค์์ ์ฐธ๊ณ )
-
CPU ์ค์ผ์ค๋ง์ด ํ์ํ ๊ฒฝ์ฐ๋ ํ๋ก์ธ์ค์๊ฒ ๋ค์๊ณผ ๊ฐ์ ์ํ ๋ณํ๊ฐ ์๋ ๊ฒฝ์ฐ์ด๋ค.
- Running -> Blocked (์ : I/O ์์ฒญํ๋ ์์คํ ์ฝ)
- Running -> Ready (์ : ํ ๋น์๊ฐ๋ง๋ฃ ๋ก timer interrupt)
- Blocked -> Ready (์ : I/O ์๋ฃ ํ ์ธํฐ๋ฝํธ)
- Terminate
-
๋น์ ์ ํ 1 ~ 4์์์ ์ค์ผ์ค๋ง์ nonpreemptive(=๊ฐ์ ๋ก ๋นผ์์ง ์๊ณ ์์ง ๋ฐ๋ฉ)
-
์ ์ ํ All other scheduling is preemptive(=๊ฐ์ ๋ก ๋นผ์์)
-
CPU utilization(์ด์ฉ๋ฅ ) - ์์คํ ์ ์ฅ์ ์ฑ๋ฅ, ์ฒ๋
- keep the CPU as busy as possible
-
Throughput(์ฒ๋ฆฌ๋) - ์์คํ ์ ์ฅ์ ์ฑ๋ฅ, ์ฒ๋
- of processes that complete their execution per time unit
-
Turnaround time (์์์๊ฐ, ๋ฐํ์๊ฐ) - ์ฌ์ฉ์ ์ ์ฅ์ ์ฑ๋ฅ, ์ฒ๋
- amount of time to execute a particular process
-
Waiting time (๋๊ธฐ ์๊ฐ) - ์ฌ์ฉ์ ์ ์ฅ์ ์ฑ๋ฅ, ์ฒ๋
- amount of time a process has been waiting in the ready queue
-
Response time (์๋ต ์๊ฐ) - ์ฌ์ฉ์ ์ ์ฅ์ ์ฑ๋ฅ, ์ฒ๋
- amount of time it takes from when a request was submitted until the first response is produced. not output (for time-sharing environment)
- FCFS (First-Come First-Served)
- SJF (Shortest-Job-First)
- SRTF (Shortest-Remaining-Time-First)
- Priority Scheduling
- RR (Round Robin)
- Multilevel Queue
- Multilevel Feedback Queue
- ์์ : ํ์ฅ์ค ์ค์ผ์ค๋ง(๋ณ๋น ์๋ ์ฌ๋์ด ์์์ ํ์ฅ์ค์ ์ ์ ํ๊ณ ์์ผ๋ฉด ์๋ ์์์ ๊ฐ์ ์ผ์ด ๋ฒ์ด์ง๋ค.)
-
๋น์ ์ ํ ์ค์ผ์ค๋ง (์ ์ฐฉ์์ผ๋ก ๋์ํ๊ธฐ ๋๋ฌธ์ ์ข์ ์ค์ผ์ค๋ง์ ์๋๋ค. ์์ ์ ์ฐฉ์์ผ๋ก ๋์ฐฉํ ํ๋ก๊ทธ๋จ์ waiting์๊ฐ์ ๋ฐ๋ผ ์ ์ฒด waiting์๊ฐ์ ์ํฅ์ ๋ง์ด ์ค๋ค.)
-
Example
- Process Burst Time
- P1 24
- P2 3
- P3 3
-
ํ๋ก์ธ์ค์ ๋์ฐฉ ์์
-
P1, P2, P3
- P1(0-24)
- P2(24-27)
- P3(27-30)
-
Wating time for P1 = 0; P2 = 24; P3 = 27
-
Average wating time : (0 + 24 + 27 )/3 = 17
-
ํ๋ก์ธ์ค์ ๋์ฐฉ์์๊ฐ ๋ค์๊ณผ ๊ฐ๋ค๊ณ ํ์.
-
P2, P3, P1
- P1(0-3)
- P2(3-6)
- P3(6-30)
-
Waiting time for P1 = 6; P2 = 0; P3=3;
-
Average waiting time : (6 + 0 + 3) /3 =3
-
Much better than previous case
-
Convoy effect : short process behind long process
- ๊ฐ ํ๋ก์ธ์ค์ ๋ค์๋ฒ CPU burst time์ ๊ฐ์ง๊ณ ์ค์ผ์ค๋ง์ ํ์ฉ
- CPU burst time์ด ๊ฐ์ฅ ์งง์ ํ๋ก์ธ์ค๋ฅผ ์ ์ผ ๋จผ์ ์ค์ผ์ค
- Two schemes :
- Nonpreemptive ๋ฒ์
- ์ผ๋จ CPU๋ฅผ ์ก์ผ๋ฉด ์ด๋ฒ CPU burst๊ฐ ์๋ฃ๋ ๋๊น์ง CPU๋ฅผ ์ ์ (preemption) ๋นํ์ง ์์
- Preemptive ๋ฒ์
- ํ์ฌ ์ํ์ค์ธ ํ๋ก์ธ์ค์ ๋จ์ burst time๋ณด๋ค ๋ ์งง์ CPU burst time์ ๊ฐ์ง๋ ์๋ก์ด ํ๋ก์ธ์ค๊ฐ ๋์ฐฉํ๋ฉด CPU๋ฅผ ๋นผ์๊น
- ์ด ๋ฐฉ๋ฒ์ Shortest-Remaining-Time-First(SRTF)์ด๋ผ๊ณ ๋ ๋ถ๋ฅธ๋ค.
- Nonpreemptive ๋ฒ์
- SJF is optimal
- ์ฃผ์ด์ง ํ๋ก์ธ์ค๋ค์ ๋ํด minimum average waiting time์ ๋ถ์ (Preemptive ๋ฒ์ )
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0.0 | 7 |
P2 | 2.0 | 4 |
P3 | 4.0 | 1 |
P4 | 5.0 | 4 |
- SJF (non-preemptive)
- P1(0-7)
- P3(7-8)
- P2(8-12)
- P4(12-16)
- Average waiting time = (0 + 6 + 3 + 7)/4 = 4
Process | Arrival Time | Burst Time |
---|---|---|
P1 | 0.0 | 7 |
P2 | 2.0 | 4 |
P3 | 4.0 | 1 |
P4 | 5.0 | 4 |
- SJF (preemptive)
- P1(0-2)
- P2(2-4)
- P3(4-5)
- P2(5-7)
- P4(7-11)
- P1(11-16)
- Average waiting time = (9 + 1 + 0 + 2)/4 = 3
- Priority number (integer) is associated with each process
- hightest priority๋ฅผ ๊ฐ์ง ํ๋ก์ธ์ค์๊ฒ CPU ํ ๋น
(smallest integer = highest priority)
- Preemptive
- nonpreemptive
- SJF๋ ์ผ์ข
์ Priority scheduling์ด๋ค.
- priority = predicted next CPU burst time
- Problem
- Starvation(๊ธฐ์ ํ์) low priority processes may never execute.
- Solution
- Aging(๋ ธํ) as time progresses increase the priority of the process.
- ๋ค์๋ฒ CPU burst time์ ์ด๋ป๊ฒ ์ ์ ์๋๊ฐ ? (input data, branch, user...)
- ์ถ์ (estimate)๋ง์ด ๊ฐ๋ฅํ๋ค.
- ๊ณผ๊ฑฐ์ CPU burst time์ ์ด์ฉํด์ ์ถ์ (์์ธก)
(exponential averaging)
- t[n](n๋ฒ์งธ ์ค์ CPU ์ฌ์ฉ์๊ฐ) = actuallength of n^CPU burst
- r[n+1](ํ์ฐ, n+1๋ฒ์งธ CPU ์ฌ์ฉ์ ์์ธกํ ์๊ฐ) - predicted value for the next CPU burst
- a(์ํ), 0 <= a(์ํ) <= 1
- Define : r[n+1] = a[tn] + (1-a)r[n]
-
๊ฐ ํ๋ก์ธ์ค๋ ๋์ผํ ํฌ๊ธฐ์ ํ ๋น ์๊ฐ(time quantum)์ ๊ฐ์ง (์ผ๋ฐ์ ์ผ๋ก 10-100 milliseconds)
-
ํ ๋น ์๊ฐ์ด ์ง๋๋ฉด ํ๋ก์ธ์ค๋ ์ ์ (preempted)๋นํ๊ณ ready queue์ ์ ์ผ ๋ค์ ๊ฐ์ ๋ค์ ์ค์ ์ ๋ค.
-
n๊ฐ์ ํ๋ก์ธ์ค๊ฐ ready queue์ ์๊ณ ํ ๋น ์๊ฐ์ด q time unit์ธ ๊ฒฝ์ฐ ๊ฐ ํ๋ก์ธ์ค๋ ์ต๋ q time unit ๋จ์๋ก CPU ์๊ฐ์ 1/n์ ์ป๋๋ค.
- ์ด๋ค ํ๋ก์ธ์ค๋ (n-1)q time unit ์ด์ ๊ธฐ๋ค๋ฆฌ์ง ์๋๋ค.
-
Performance
- q large -> FCFS
- q small -> context switch ์ค๋ฒํค๋๊ฐ ์ปค์ง๋ค.
Process | Burst Time |
---|---|
P1 | 53 |
P2 | 17 |
P3 | 68 |
P4 | 24 |
- The Gantt chart is :
P1 | P2 | P3 | P4 | P1 | P3 | P4 | P1 | P3 | P3 |
---|---|---|---|---|---|---|---|---|---|
0-20 | 20-37 | 37-57 | 57-77 | 77-97 | 97-117 | 117-121 | 121-134 | 134-154 | 154-162 |
- ์ผ๋ฐ์ ์ผ๋ก SJF๋ณด๋ค average turnaround time์ด ๊ธธ์ง๋ง response time์ ๋ ์งง๋ค.
- Ready Queue๋ฅผ ์ฌ๋ฌ ๊ฐ๋ก ๋ถํ
- foreground (interactive)
- background (batch - no human interaction)
- ๊ฐ ํ๋ ๋
๋ฆฝ์ ์ธ ์ค์ผ์ค๋ง ์๊ณ ๋ฆฌ์ฆ์ ๊ฐ์ง
- foreground - RR
- background - FCFS
- ํ์ ๋ํ ์ค์ผ์ค๋ง์ด ํ์
- Fixed priority scheduling
- serve all from foreground then from background
- Possibility of starvation
- Time slice
- ๊ฐ ํ์ CPU time์ ์ ์ ํ ๋น์จ๋ก ํ ๋น
- Eg., 80% to foreground in RR, 20% to background in FCFS
- Fixed priority scheduling
- system processes
- interactive processes
- interactive editing processes
- batch processes
- student processes
- ํ๋ก์ธ์ค๊ฐ ๋ค๋ฅธ ํ๋ก ์ด๋ ๊ฐ๋ฅ
- ์์ด์ง(aging)์ ์ด์ ๊ฐ์ ๋ฐฉ์์ผ๋ก ๊ตฌํํ ์ ์๋ค.
- Multilevel-feedback-queue scheduler๋ฅผ ์ ์ํ๋ ํ๋ผ๋ฏธํฐ๋ค
- Queue์ ์
- ๊ฐ ํ์ scheduling algorithm
- Process๋ฅผ ์์ ํ๋ก ๋ณด๋ด๋ ๊ธฐ์ค
- Process๋ฅผ ํ์ ํ๋ก ๋ด์ซ๋ ๊ธฐ์ค
- ํ๋ก์ธ์ค๊ฐ CPU ์๋น์ค๋ฅผ ๋ฐ์ผ๋ ค ํ ๋ ๋ค์ด๊ฐ ํ๋ฅผ ๊ฒฐ์ ํ๋ ๊ธฐ์ค
-
Three queues
- Q[0] - time quantum 8 milliseconds
- Q[1] - time quantum 16 milliseconds
- Q[2] - FCFS
-
Scheduling
- new job์ด queue Q[0]๋ก ๋ค์ด๊ฐ
- CPU๋ฅผ ์ก์์ ํ ๋น ์๊ฐ 8 milliseconds ๋์ ์ํ๋จ
- 8 milliseconds ๋์ ๋ค ๋๋ด์ง ๋ชปํ์ผ๋ฉด queue Q[1]ใ ก๋ก ๋ด๋ ค๊ฐ
- Q[1]์ ์ค์์ ๊ธฐ๋ค๋ ธ๋ค๊ฐ CPU๋ฅผ ์ก์์ 16ms๋์ ์ํ๋จ
- 16ms์ ๋๋ด์ง ๋ชปํ ๊ฒฝ์ฐ queue Q[2]๋ก ์ซ๊ฒจ๋จ
- CPU๊ฐ ์ฌ๋ฌ ๊ฐ์ธ ๊ฒฝ์ฐ ์ค์ผ์ค๋ง์ ๋์ฑ ๋ณต์กํด์ง
- Homogeneous processor์ธ ๊ฒฝ์ฐ
- Queue์ ํ์ค๋ก ์ธ์์ ๊ฐ ํ๋ก์ธ์๊ฐ ์์์ ๊บผ๋ด๊ฐ๊ฒ ํ ์ ์๋ค.
- ๋ฐ๋์ ํน์ ํ๋ก์ธ์์์ ์ํ๋์ด์ผ ํ๋ ํ๋ก์ธ์ค๊ฐ ์๋ ๊ฒฝ์ฐ์๋ ๋ฌธ์ ๊ฐ ๋ ๋ณต์กํด์ง
- Load sharing
- ์ผ๋ถ ํ๋ก์ธ์์ job์ด ๋ชฐ๋ฆฌ์ง ์๋๋ก ๋ถํ๋ฅผ ์ ์ ํ ๊ณต์ ํ๋ ๋ฉ์ปค๋์ฆ ํ์
- ๋ณ๊ฐ์ ํ๋ฅผ ๋๋ ๋ฐฉ๋ฒ VS ๊ณต๋ ํ๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ
- Symmetric Multiprocessing (SMP)
- ๊ฐ ํ๋ก์ธ์๊ฐ ๊ฐ์ ์์์ ์ค์ผ์ค๋ง ๊ฒฐ์
- Asymmetric multiprocessing
- ํ๋์ ํ๋ก์ธ์๊ฐ ์์คํ ๋ฐ์ดํฐ์ ์ ๊ทผ๊ณผ ๊ณต์ ๋ฅผ ์ฑ ์์ง๊ณ ๋๋จธ์ง ํ๋ก์ธ์๋ ๊ฑฐ๊ธฐ์ ๋ฐ๋ฆ
- Hard real-time systems
- Hard real-time task๋ ์ ํด์ง ์๊ฐ ์์ ๋ฐ๋์ ๋๋ด๋๋ก ์ค์ผ์ค๋งํด์ผ ํจ
- Soft real-time computing
- Soft real-time task๋ ์ผ๋ฐ ํ๋ก์ธ์ค์ ๋นํด ๋์ priority๋ฅผ ๊ฐ๋๋ก ํด์ผ ํจ
- Local Scheduling
- User level thread์ ๊ฒฝ์ฐ ์ฌ์ฉ์ ์์ค์ thread library์ ์ํด ์ด๋ค thread๋ฅผ ์ค์ผ์คํ ์ง ๊ฒฐ์
- Global Scheduling
- Kernel level thread์ ๊ฒฝ์ฐ ์ผ๋ฐ ํ๋ก์ธ์ค์ ๋ง์ฐฌ๊ฐ์ง๋ก ์ปค๋์ ๋จ๊ธฐ ์ค์ผ์ค๋ฌ๊ฐ ์ด๋ค thread๋ฅผ ์ค์ผ์คํ ์ง ๊ฒฐ์
-
Queueing models
- ํ๋ฅ ๋ถํฌ๋ก ์ฃผ์ด์ง๋ arrival rate์ service rate๋ฑ์ ํตํด ๊ฐ์ข performance index ๊ฐ์ ๊ณ์ฐ
-
Implementation(๊ตฌํ) & Measurement(์ฑ๋ฅ ์ธก์ )
- ์ค์ ์์คํ ์ ์๊ณ ๋ฆฌ์ฆ์ ๊ตฌํํ์ฌ ์ค์ ์์ (workload)์ ๋ํด์ ์ฑ๋ฅ์ ์ธก์ ๋น๊ต
-
Simulation(๋ชจ์ ์คํ)
- ์๊ณ ๋ฆฌ์ฆ์ ๋ชจ์ ํ๋ก๊ทธ๋จ์ผ๋ก ์์ฑ ํ trace๋ฅผ ์ ๋ ฅ์ผ๋ก ํ์ฌ ๊ฒฐ๊ณผ ๋น๊ต
- S-box(Memory Address Space)๋ฅผ ๊ณต์ ํ๋ E-box(CPU Process)๊ฐ ์ฌ๋ฟ ์๋ ๊ฒฝ์ฐ Race Condition์ ๊ฐ๋ฅ์ฑ์ด ์์
- Multiprocessor system
- ๊ณต์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ ํ๋ก์ธ์ค๋ค, ์ปค๋ ๋ด๋ถ๋ฐ์ดํฐ๋ฅผ ์ ๊ทผํ๋ ๋ฃจํด๋ค ๊ฐ (์ : ์ปค๋๋ชจ๋ ์ํ ์ค ์ธํฐ๋ฝํธ๋ก ์ปค๋๋ชจ๋ ๋ค๋ฅธ ๋ฃจํด ์ํ์)
- kernel ์ํ ์ค ์ธํฐ๋ฝํธ ๋ฐ์ ์
- Process๊ฐ system call์ ํ์ฌ kernel mode๋ก ์ํ์ค์ธ๋ฐ context switch๊ฐ ์ผ์ด๋๋ ๊ฒฝ์ฐ
- Multiprocessor์์ shared memory ๋ด์ kernel data
- interrupt handler vs kernel
interrupt handler Count-- kernel Count++ (1. load, 2. Inc, 3. Store)
์ปค๋์ด ์ด๋ค ์์ ์ค์ ์์ ๋ ์ธํฐ๋ฝํธ ์์ฒญ์ด ์๋ ๊ธฐ์กด ์์ ์ ๋ค ํ๋ค์ ์ธํฐ๋ฝํธ ์ฒ๋ฆฌ ๋ฃจํด์ผ๋ก ๊ฐ๋ค. ์์ ๊ฐ์ ๊ฒฝ์ฐ๋ ์นด์ดํธ๊ฐ 1 ์ฆ๊ฐํจ ์ปค๋์์ Count++ ์์ ์ค ์ธํฐ๋ฝํธ๋ก Count--๊ฐ ๋ค์ด์ฌ ๋์ ์ํฉ
- ์ปค๋๋ชจ๋ running ์ค interrupt๊ฐ ๋ฐ์ํ์ฌ ์ธํฐ๋ฝํธ ์ฒ๋ฆฌ๋ฃจํด์ด ์ํ
- ์์ชฝ ๋ค ์ปค๋ ์ฝ๋์ด๋ฏ๋ก kernel address space ๊ณต์
- user mode
- System call
- kernel mode
- Return from kernel
- user mode
- System call
- kernel mode
- ๋ ํ๋ก์ธ์ค์ address space๊ฐ์๋ data sharing์ด ์์
- ๊ทธ๋ฌ๋ system call์ ํ๋ ๋์์๋ kernel address space์ data๋ฅผ accessํ๊ฒ ๋จ(share)
- ์ด ์์ ์ค๊ฐ์ CPU๋ฅผ preemptํด๊ฐ๋ฉด race condition ๋ฐ์
- System call read()
- Time quantum expires & P[B] needs CPU. P[A]๋ CPU๋ฅผ preempt ๋นํจ (while in kernel !)
- CPU ๋๋๋ ค ๋ฐ์
- ํด๊ฒฐ์ฑ : ์ปค๋๋ชจ๋์์ ์ํ์ค์ผ๋๋ CPU๋ฅผ preemptํ์ง ์์ ์ปค๋๋ชจ๋์์ ์ฌ์ฉ์ ๋ชจ๋๋ก ๋์๊ฐ ๋ preempt
์ด๋ค CPU๊ฐ ๋ง์ง๋ง์ผ๋ก count๋ฅผ storeํ๋๊ฐ ? >>> race condition multiprocessor์ ๊ฒฝ์ฐ interrupt enable/disable๋ก ํด๊ฒฐ๋์ง ์์
- ๋ฐฉ๋ฒ1. ํ๋ฒ์ ํ๋์ CPU๋ง์ด ์ปค๋์ ๋ค์ด๊ฐ ์ ์๊ฒ ํ๋ ๋ฐฉ๋ฒ
- ๋ฐฉ๋ฒ2. ์ปค๋ ๋ด๋ถ์ ์๋ ๊ฐ ๊ณต์ ๋ฐ์ดํฐ์ ์ ๊ทผํ ๋๋ง๋ค ๊ทธ ๋ฐ์ดํฐ์ ๋ํ lock / unlock์ ํ๋ ๋ฐฉ๋ฒ
-
๊ณต์ ๋ฐ์ดํฐ(shared data)์ ๋์ ์ ๊ทผ(concurrent access)๋ ๋ฐ์ดํฐ์ ๋ถ์ผ์น(inconsistency)๋ฅผ ๋ฐ์์ํฌ ์ ์๋ค.
-
์ผ๊ด์ฑ(consistency)์ ์ง๋ฅผ ์ํด์๋ ํ๋ ฅ ํ๋ก์ธ์ค(cooperating process)๊ฐ์ ์คํ ์์(orderly execution)์ ์ ํด์ฃผ๋ ๋ฉ์ปค๋์ฆ ํ์
-
Race condition
- ์ฌ๋ฌ ํ๋ก์ธ์ค๋ค์ด ๋์์ ๊ณต์ ๋ฐ์ดํฐ๋ฅผ ์ ๊ทผํ๋ ์ํฉ
- ๋ฐ์ดํฐ์ ์ต์ข ์ฐ์ฐ ๊ฒฐ๊ณผ๋ ๋ง์ง๋ง์ ๊ทธ ๋ฐ์ดํฐ๋ฅผ ๋ค๋ฃฌ ํ๋ก์ธ์ค์ ๋ฐ๋ผ ๋ฌ๋ผ์ง
-
race condition์ ๋ง๊ธฐ ์ํด์๋ concurrent process๋ ๋๊ธฐํ(synchronize)๋์ด์ผ ํ๋ค.
- n๊ฐ์ ํ๋ก์ธ์ค๊ฐ ๊ณต์ ๋ฐ์ดํฐ๋ฅผ ๋์์ ์ฌ์ฉํ๊ธฐ๋ฅผ ์ํ๋ ๊ฒฝ์ฐ
- ๊ฐ ํ๋ก์ธ์ค์ code segment์๋ ๊ณต์ ๋ฐ์ดํฐ๋ฅผ ์ ๊ทผํ๋ ์ฝ๋์ธ critical section์ด ์กด์ฌ.
- Problem
- ํ๋์ ํ๋ก์ธ์ค๊ฐ critical section์ ์์ ๋ ๋ค๋ฅธ ๋ชจ๋ ํ๋ก์ธ์ค๋ critical section์ ๋ค์ด๊ฐ ์ ์์ด์ผ ํ๋ค.
-
๋ ๊ฐ์ ํ๋ก์ธ์ค๊ฐ ์๋ค๊ณ ๊ฐ์ P[0], P[1]
-
ํ๋ก์ธ์ค๋ค์ ์ผ๋ฐ์ ์ธ ๊ตฌ์กฐ
do { entry section critical section exit section remainder section }while(1);
- ํ๋ก์ธ์ค๋ค์ ์ํ์ ๋๊ธฐํ(synchronize)๋ฅผ ์ํด ๋ช๋ช ๋ณ์๋ฅผ ๊ณต์ ํ ์ ์๋ค.
synchronization variable
-
Mutual Exclusion (์ํธ๋ฐฐ์ )
- ํ๋ก์ธ์ค Pi๊ฐ critical section ๋ถ๋ถ์ ์ํ์ค์ด๋ฉด ๋ค๋ฅธ ๋ชจ๋ ํ๋ก์ธ์ค๋ค์ ๊ทธ๋ค์ critical section์ ๋ค์ด๊ฐ๋ฉด ์ ๋๋ค.
-
Progress(์งํ)
- ์๋ฌด๋ critical section์ ์์ง ์์ ์ํ์์ critical section์ ๋ค์ด๊ฐ๊ณ ์ ํ๋ ํ๋ก์ธ์ค๊ฐ ์์ผ๋ฉด critical section์ ๋ค์ด๊ฐ๊ฒ ํด์ฃผ์ด์ผ ํ๋ค.
-
Bounded Waiting(์ ํ ๋๊ธฐ)
- ํ๋ก์ธ์ค๊ฐ critical section์ ๋ค์ด๊ฐ๋ ค๊ณ ์์ฒญํ ํ๋ถํฐ ๊ทธ ์์ฒญ์ด ํ์ฉ๋ ๋๊น์ง ๋ค๋ฅธ ํ๋ก์ธ์ค๋ค์ด critical section์ ๋ค์ด๊ฐ๋ ํ์์ ํ๊ณ๊ฐ ์์ด์ผ ํ๋ค.
-
๊ฐ์
- ๋ชจ๋ ํ๋ก์ธ์ค์ ์ํ ์๋๋ 0๋ณด๋ค ํฌ๋ค.
- ํ๋ก์ธ์ค๋ค ๊ฐ์ ์๋์ ์ธ ์ํ ์๋๋ ๊ฐ์ ํ์ง ์๋๋ค.
-
Synchronization variable int turn; initially turn = 0; >> P[i] can enter its critical section if (turn == i)
-
Process P
do { while (turn != 0); /* My turn ? */ critical section turn = 1; /* Now it's your turn */ remainder section } while(1);
- Satisfies mutual exclusion, but not progress
- ์ฆ, ๊ณผ์์๋ณด : ๋ฐ๋์ ๊ต๋๋ก ๋ค์ด๊ฐ์ผ๋ง ํจ(swap-turn)
๊ทธ๊ฐ turn์ ๋ด ๊ฐ์ผ๋ก ๋ฐ๊ฟ์ค์ผ๋ง ๋ด๊ฐ ๋ค์ด๊ฐ ์ ์์ ํน์ ํ๋ก์ธ์ค๊ฐ
๋ ๋น๋ฒํ criticial sectiovariables
- n์ ๋ค์ด๊ฐ์ผ ํ๋ค๋ฉด ?
- ์ฆ, ๊ณผ์์๋ณด : ๋ฐ๋์ ๊ต๋๋ก ๋ค์ด๊ฐ์ผ๋ง ํจ(swap-turn)
๊ทธ๊ฐ turn์ ๋ด ๊ฐ์ผ๋ก ๋ฐ๊ฟ์ค์ผ๋ง ๋ด๊ฐ ๋ค์ด๊ฐ ์ ์์ ํน์ ํ๋ก์ธ์ค๊ฐ
๋ ๋น๋ฒํ criticial sectiovariables
-
Synchronization variables
- boolean flag[2]; initially flag [๋ชจ๋] = false; /no one is in CS/
- "P[1] ready to enter its critical section" (flag[i] == true)
-
Process P[i]
do { flag[i] = true; /* Pretend I am in */ while (flag[j]); /* Is he also in ? then wait */ critical section flag[i] = false ; /* I am out now */ remainder section } while(1);
- Satisfies mutual exclusion, but not progress requirement.
- ๋ ๋ค 2ํ๊น์ง ์ํ ํ ๋์ ์์ด ์๋ณดํ๋ ์ํฉ ๋ฐ์ ๊ฐ๋ฅ
- Combined synchronization variables of algorithms 1 and 2
- Process P[i]
do {
flag [i] = true; /* My intention is to enter ... */
turn = j; /* Set to his turn */
while(flag[j] && turn == j); /* wait only if ... */
critical section
flag[i] = false;
remainder section
}while(1)
- Meets all three requirements; solves the critical section problem for two processes.
- Busy Waiting!(=spin lock!) (๊ณ์ CPU์ memory๋ฅผ ์ฐ๋ฉด์ wait)
- ํ๋์จ์ด์ ์ผ๋ก Test & modify๋ฅผ atomicํ๊ฒ ์ํํ ์ ์๋๋ก ์ง์ํ๋ ๊ฒฝ์ฐ ์์ ๋ฌธ์ ๋ ๊ฐ๋จํ ํด๊ฒฐ
- Test_and_set(a) ์ธ์คํธ๋ญ์ ์ด ๊ธฐ์กด ๊ฐ์ Read ํ๋ฉด์ ์๋ก ๊ฐ์ ์ค์ ํ๋ ๊ทธ๋ฐ ๊ธฐ๋ฅ์ ํ๋ค. (1.Read, 2.TRUE )
- Mutual Exclusion with Test & Set
Synchronization variable:
boolean lock = false;
Process P[i]
do {
while (Test_and_Set(lock));
critical section
lock = false;
remainder section
}
- ๊ณต์ ์์์ ํ๋ํ๊ณ ๋ฐ๋ฉํ๋ ๊ฒ์ ์ฒ๋ฆฌํด์ค
-
์์ ๋ฐฉ์๋ค์ ์ถ์ํ์ํด
-
Semaphore S
- integer variable
- ์๋์ ๋ ๊ฐ์ง atomic ์ฐ์ฐ์ ์ํด์๋ง ์ ๊ทผ ๊ฐ๋ฅ (P ์ฐ์ฐ(๊ณต์ ๋ฐ์ดํฐ ํ๋), V ์ฐ์ฐ(๊ณต์ ๋ฐ์ดํฐ๋ฅผ ๋ค ์ฌ์ฉํ๊ณ ๋ฐ๋ฉํ๋ ๊ณผ์ ))
P(S) : while(S<=0) do no-op (i.e. wait) S--; If positive, decrement-&-enter. Otherwise, wait until positive (busy-wait) V(S) : S++;
Synchronization variable
semaphore mutex; /* initially 1 : 1๊ฐ๊ฐ CS์ ๋ค์ด๊ฐ ์ ์๋ค. */
Process P[i]
do {
P(mutex); /* If positive, dec-&-enter,Otherwise, wait. */
critical section
V(mutex); /* Increment semaphore */
remainder section
} while(1);
- busy-wait์ ํจ์จ์ ์ด์ง ๋ชปํจ(=spin lock)
- Block & Wakeup ๋ฐฉ์์ ๊ตฌํ (=sleep lock) >> next page
- Semaphore๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ์ ์
typedef struct
{
int value; /* semaphore */
struct process *L; /* process wait queue */
} semaphore;
-
block๊ณผ wakeup์ ๋ค์๊ณผ ๊ฐ์ด ๊ฐ์
- block : ์ปค๋์ block์ ํธ์ถํ ํ๋ก์ธ์ค๋ฅผ suspend์ํด ์ด ํ๋ก์ธ์ค์ PCB๋ฅผ semaphore์ ๋ํ wait queue์ ๋ฃ์
- wakeup(P) : block๋ ํ๋ก์ธ์ค P๋ฅผ wakeup ์ํด ์ด ํ๋ก์ธ์ค์ PCB๋ฅผ ready queue๋ก ์ฎ๊น
Semaphore : value-L >> PCB >> PCB >> PCB
-
block/wakeup version of P() & V()
-
Semaphore ์ฐ์ฐ์ด ์ด์ ๋ค์๊ณผ ๊ฐ์ด ์ ์๋จ
P(S) : S.value--; /* prepare to enter */
if (S.value < 0 ) /* Oops, negative, I cannot enter */
{
add this process to S.L;
block();
}
V(S) : S.value++;
if (S.value <= 0 ) {
remove a process P from S.L;
wakeup(P);
}
-
Busy-wait v.s. Block/wakeup
-
Block/wakeup overhead v.s. Critical section ๊ธธ์ด
- Critical section์ ๊ธธ์ด๊ฐ ๊ธด ๊ฒฝ์ฐ Block/Wakeup์ด ์ ๋น
- Critical section์ ๊ธธ์ด๊ฐ ๋งค์ฐ ์งง์ ๊ฒฝ์ฐ Block/Wakeup ์ค๋ฒํค๋๊ฐ busy-wait ์ค๋ฒํค๋๋ณด๋ค ๋ ์ปค์ง ์ ์์
- ์ผ๋ฐ์ ์ผ๋ก๋ Block/wakeup ๋ฐฉ์์ด ๋ ์ข์
-
Counting semaphore
- ๋๋ฉ์ธ์ด 0 ์ด์์ธ ์์์ ์ ์๊ฐ
- ์ฃผ๋ก resource counting์ ์ฌ์ฉ
-
Binary semaphore (=mutex)
- 0 ๋๋ 1 ๊ฐ๋ง ๊ฐ์ง ์ ์๋ semaphore
- ์ฃผ๋ก mutual exclusion (lock/unlock) ์ฌ์ฉ
- Deadlock
- ๋ ์ด์์ ํ๋ก์ธ์ค๊ฐ ์๋ก ์๋๋ฐฉ์ ์ํด ์ถฉ์กฑ๋ ์ ์๋ event๋ฅผ ๋ฌดํํ ๊ธฐ๋ค๋ฆฌ๋ ํ์
- S์ Q๊ฐ 1๋ก ์ด๊ธฐํ๋ semaphore๋ผ ํ์.
- P[0] P[1]
- P(S); P(Q); ํ๋์ฉ ์ฐจ์ง.
- P(Q); P(S); ์๋๋ฐฉ ๊ฒ์ ์๊ตฌ
- ..... .....
- V(S); V(Q); ์ฌ๊ธฐ์์ผ releaseํจ
- V(Q); V(S);
- Starvation
- indefinite blocking. ํ๋ก์ธ์ค๊ฐ suspend๋ ์ด์ ์ ํด๋นํ๋ ์ธ๋งํฌ์ด ํ์์ ๋น ์ ธ๋๊ฐ ์ ์๋ ํ์.
- Bounded-Buffer Problem (Producer-Consumer Problem)
- Readers and Writers Problem
- Dining-Philosophers Problem
- Empty ๋ฒํผ๊ฐ ์๋์ ? (์์ผ๋ฉด ๊ธฐ๋ค๋ฆผ)
- ๊ณต์ ๋ฐ์ดํฐ์ lock์ ๊ฑด๋ค.
- Empty buffer์ ๋ฐ์ดํฐ ์ ๋ ฅ ๋ฐ buffer ์กฐ์
- Lock์ ํผ๋ค.
- Full buffer ํ๋ ์ฆ๊ฐ
- full ๋ฒํผ๊ฐ ์๋์ ? (์์ผ๋ฉด ๊ธฐ๋ค๋ฆผ)
- ๊ณต์ ๋ฐ์ดํฐ์ lock์ ๊ฑธ๋ค.
- Full buffer์์ ๋ฐ์ดํฐ ๊บผ๋ด๊ณ buffer ์กฐ์
- Lock์ ํผ๋ค.
- empty buffer ํ๋ ์ฆ๊ฐ.
- buffer ์์ฒด ๋ฐ buffer ์กฐ์ ๋ณ์(empty/full buffer์ ์์ ์์น)
- mutual exclusion -> Need binary semaphore (shared data์ mutual exclusion์ ์ํด)
- resource count -> Need integer semaphore (๋จ์ full/empty buffer์ ์ ํ์)
- semaphore full = 0, empty = n, mutex = 1;
do {
...
P(empty);
P(mutex);
...
add x to buffer
...
V(mutex);
V(full);
}while(1);
do {
P(full)
P(mutex);
...
remove an item from buffer to y
...
V(mutex);
V(empty);
...
consume the item in y
...
}while(1);
- ํ process๊ฐ DB์ write ์ค์ผ ๋ ๋ค๋ฅธ process๊ฐ ์ ๊ทผํ๋ฉด ์๋จ
- read๋ ๋์์ ์ฌ๋ฟ์ด ํด๋ ๋จ
- solution
- Writer๊ฐ DB์ ์ ๊ทผ ํ๊ฐ๋ฅผ ์์ง ์ป์ง ๋ชปํ ์ํ์์๋ ๋ชจ๋ ๋๊ธฐ์ค์ธ Reader๋ค์ ๋ค DB์ ์ ๊ทผํ๊ฒ ํด์ค๋ค.
- Writer๋ ๋๊ธฐ ์ค์ธ Reader๊ฐ ํ๋๋ ์์ ๋ DB ์ ๊ทผ์ด ํ์ฉ๋๋ค.
- ์ผ๋จ Writer๊ฐ DB์ ์ ๊ทผ ์ค์ด๋ฉด Reader๋ค์ ์ ๊ทผ์ด ๊ธ์ง๋๋ค.
- Writer๊ฐ DB์์ ๋น ์ ธ๋๊ฐ์ผ๋ง Reader์ ์ ๊ทผ์ด ํ์ฉ๋๋ค.
- DB ์์ฒด
- readcount; /_ ํ์ฌ DB์ ์ ๊ทผ ์ค์ธ Reader์ ์ _/
- mutex /_ ๊ณต์ ๋ณ์ readcount๋ฅผ ์ ๊ทผํ๋ ์ฝ๋(critical section)์ mutual exclusion ๋ณด์ฅ์ ์ํด ์ฌ์ฉ _/
- db /_ Reader์ writer๊ฐ ๊ณต์ DB ์์ฒด๋ฅผ ์ฌ๋ฐ๋ฅด๊ฒ ์ ๊ทผํ๊ฒ ํ๋ ์ญํ _/
int readcount = 0; DB ์์ฒด;
Synchronization variables semaphore mutex = 1, db = 1;
- P(db);
- ...
- writing DB is performed
- ...
- V(db)
- P(mutex);
- readcount++
- if(readcount==1)
- P(db); /_ block writer _/
- if (readcount == 1) /_ block writer _/
- V(mutex); /readers follow/
- ...
- reading DB is performed
- ...
- P(mutex);
- readcount--;
- if(readcount==0) V(db); /enable writer/
- V(mutex);
- ! Starvation ๋ฐ์ ๊ฐ๋ฅ
- semaphore chopstick[5] /_ Initially all values are 1 _/
do {
P(chopstick[i]);
P(chopstick[(i+1)%5]);
...
eat();
...
V(chopstick[i]);
V(chopstick[(i+1)%5]);
...
think();
...
}while(1);
-
์์ solution์ ๋ฌธ์ ์
- Deadlock ๊ฐ๋ฅ์ฑ์ด ์๋ค.
- ๋ชจ๋ ์ฒ ํ์๊ฐ ๋์์ ๋ฐฐ๊ฐ ๊ณ ํ์ ธ ์ผ์ชฝ ์ ๊ฐ๋ฝ์ ์ง์ด๋ฒ๋ฆฐ ๊ฒฝ์ฐ
-
ํด๊ฒฐ ๋ฐฉ์
- 4๋ช ์ ์ฒ ํ์๋ง์ด ํ ์ด๋ธ์ ๋์์ ์์ ์ ์๋๋ก ํ๋ค.
- ์ ๊ฐ๋ฝ์ ๋ ๊ฐ ๋ชจ๋ ์ง์ ์ ์์๋์๋ง ์ ๊ฐ๋ฝ์ ์ง์ ์ ์๊ฒ ํ๋ค.
- ๋น๋์นญ
- ์ง์(ํ์) ์ฒ ํ์๋ ์ผ์ชฝ(์ค๋ฅธ์ชฝ) ์ ๊ฐ๋ฝ๋ถํฐ ์ง๋๋ก
enum {thinking, hungry, eating} state[5];
semaphore self[5]=0;
semaphore mutex=1;
do {
pickup(i);
eat();
putdown(i);
think();
}while(1);
void putdown(int i){
P(mutex);
state[i] = thinking;
test((i+4) % 5);
test((i+4) % 5);
V(mutex);
}
void pickup(int i){
P(mutex);
state[i] = hungry;
test(i);
V(mutex);
P(self[i]);
}
void test(int i){
if (state[(i+4)%5]!=eating && state[i]==hungry && state[(i+1)%5] != eating){
state[i] = eating;
V(self[i]);
}
}
- ์ฝ๋ฉํ๊ธฐ ํ๋ค๋ค.
- ์ ํ์ฑ(correctness)์ ์ ์ฆ์ด ์ด๋ ต๋ค.
- ์๋ฐ์ ํ๋ ฅ(voluntary cooperation)์ด ํ์ํ๋ค.
- ํ๋ฒ์ ์ค์๊ฐ ๋ชจ๋ ์์คํ ์ ์น๋ช ์ ์ํฅ
- V(mutex) P(mutex)
- Critical Section Critical Section
- P(mutex) P(mutex)
Mutual exclusion ๊นจ์ง Deadlock
- (ํ๋ก์ธ์ค ๋๊ธฐํ)
- (๋ณํ ์ ์ด)
๋์์ํ์ค์ธ ํ๋ก์ธ์ค ์ฌ์ด์์ abstract data type์ ์์ ํ ๊ณต์ ๋ฅผ ๋ณด์ฅํ๊ธฐ ์ํ high-level synchronization construct
monitor monitor-name
{
shared variable declarations
procedure body P[1](...){
...
}
procedure body P[2](...){
...
}
procedure body P[n](...){
...
}
{
initialization code
}
}
-
๋ชจ๋ํฐ ๋ด์์๋ ํ๋ฒ์ ํ๋์ ํ๋ก์ธ์ค๋ง์ด ํ๋ ๊ฐ๋ฅ
-
ํ๋ก๊ทธ๋๋จธ๊ฐ ๋๊ธฐํ ์ ์ฝ ์กฐ๊ฑด์ ๋ช ์์ ์ผ๋ก ์ฝ๋ฉํ ํ์์์
-
ํ๋ก์ธ์ค๊ฐ ๋ชจ๋ํฐ ์์์ ๊ธฐ๋ค๋ฆด ์ ์๋๋ก ํ๊ธฐ ์ํด
- condition variable ์ฌ์ฉ
- condition x, y;
- condition variable ์ฌ์ฉ
-
Condition variable์ wait์ signal ์ฐ์ฐ์ ์ํด์๋ง ์ ๊ทผ ๊ฐ๋ฅ
-
x.wait();
- x.wait()์ invokeํ ํ๋ก์ธ์ค๋ ๋ค๋ฅธ ํ๋ก์ธ์ค๊ฐ x.signal()์ invokeํ๊ธฐ ์ ๊น์ง suspend๋๋ค.
-
x.signal();
- x.signal()์ ์ ํํ๊ฒ ํ๋์ suspend๋ ํ๋ก์ธ์ค๋ฅผ resumeํ๋ค.
- Suspend๋ ํ๋ก์ธ์ค๊ฐ ์์ผ๋ฉด ์๋ฌด ์ผ๋ ์ผ์ด๋์ง ์๋๋ค.
- x.signal()์ ์ ํํ๊ฒ ํ๋์ suspend๋ ํ๋ก์ธ์ค๋ฅผ resumeํ๋ค.
-
monitor dining_philosopher
{
enum {thinking, hungry, eating} state[5];
condition self[5];
void pickup(int i){
state[i] = hungry;
test(i);
if (state[i] != eating)
self[i].wait(); /* wait here*/
}
}
void putdown(int i){
state[i] = thinking;
/* test left and right neighbors */
test((i+4) % 5); /* if L is waiting */
test((i+1) % 5);
}
void test(int i){
if ( (state[(i+4) % 5] != eating) && (state[i] == hungry) && (state[(i+1) %5] != eating)){
state[i] = eating;
self[i].signal(); /*wake up Pi*/
}
}
void init(){
for(int i =0; i < 5; i++)
state[i] = thinking;
}
Each Philosopher:
{
pickup(i);
eat();
putdown(i);
think();
} while(1);
- ์ผ๋ จ์ ํ๋ก์ธ์ค๋ค์ด ์๋ก๊ฐ ๊ฐ์ง ์์์ ๊ธฐ๋ค๋ฆฌ๋ฉฐ block๋ ์ํ
- ํ๋์จ์ด, ์ํํธ์จ์ด ๋ฑ์ ํฌํจํ๋ ๊ฐ๋
- (์) I/O device, CPU cycle, memory space, semaphore ๋ฑ
- ํ๋ก์ธ์ค๊ฐ ์์์ ์ฌ์ฉํ๋ ์ ์ฐจ
- Request, Allocate, Use, Release
- ์์คํ ์ 2๊ฐ์ tape drive๊ฐ ์๋ค.
- ํ๋ก์ธ์ค P[1]๊ณผ P[2] ๊ฐ๊ฐ์ด ํ๋์ tape drive๋ฅผ ๋ณด์ ํ ์ฑ ๋ค๋ฅธ ํ๋๋ฅผ ๊ธฐ๋ค๋ฆฌ๊ณ ์๋ค.
- Binary semaphores A and B
- P[0] : P[A], P[B]
- P[1] : P[B], P[A]
- ๋งค ์๊ฐ ํ๋์ ํ๋ก์ธ์ค๋ง์ด ์์์ ์ฌ์ฉํ ์ ์์
- ํ๋ก์ธ์ค๋ ์์์ ์ค์ค๋ก ๋ด์ด๋์ ๋ฟ ๊ฐ์ ๋ก ๋นผ์๊ธฐ์ง ์์
- ์์์ ๊ฐ์ง ํ๋ก์ธ์ค๊ฐ ๋ค๋ฅธ ์์์ ๊ธฐ๋ค๋ฆด ๋ ๋ณด์ ์์์ ๋์ง์๊ณ ๊ณ์ ๊ฐ์ง๊ณ ์์
- ์์์ ๊ธฐ๋ค๋ฆฌ๋ ํ๋ก์ธ์ค๊ฐ์ ์ฌ์ดํด์ด ํ์ฑ๋์ด์ผํจ
- ํ๋ก์ธ์ค P[0], P[1], ..., P[n]์ด ์์ ๋
- P[0]์ P[1]์ด ๊ฐ์ง ์์์ ๊ธฐ๋ค๋ฆผ
- P[1]์ P[2]์ด ๊ฐ์ง ์์์ ๊ธฐ๋ค๋ฆผ
- P[n-1]์ P[n]์ด ๊ฐ์ง ์์์ ๊ธฐ๋ค๋ฆผ
- P[n]์ P[0]์ด ๊ฐ์ง ์์์ ๊ธฐ๋ค๋ฆผ
- Process P = {P[1], P[2], P[3]... P[n]}
- Resource R = {R[1],R[2], ... R[n]}
- request edge P[i] > R[j]
- assignment edge R[j] > P[i]
- if only one instance per resource type, then deadlock
- if several instances per resource type, possibility of deadlock
- ์์ ํ ๋น์ Deadlock์ 4๊ฐ์ง ํ์ ์กฐ๊ฑด ์ค ์ด๋ ํ๋๊ฐ ๋ง์กฑ๋์ง ์๋๋ก ํ๋ ๊ฒ
- ์์์์ฒญ์ ๋ํ ๋ถ๊ฐ์ ์ธ ์ ๋ณด๋ฅผ ์ด์ฉํด์ deadlock์ ๊ฐ๋ฅ์ฑ์ด ์๋ ๊ฒฝ์ฐ์๋ง ์์์ ํ ๋น
- ์์คํ state๊ฐ ์๋ state๋ก ๋์์ฌ ์ ์๋ ๊ฒฝ์ฐ์๋ง ์์ ํ ๋น
- Deadlock ๋ฐ์์ ํ์ฉํ๋ ๊ทธ์ ๋ํ detection ๋ฃจํด์ ๋์ด deadlock ๋ฐ๊ฒฌ์ recover
- Deadlock์ ์์คํ ์ด ์ฑ ์์ง์ง ์์
- UNIX๋ฅผ ํฌํจํ ๋๋ถ๋ถ์ OS๊ฐ ์ฑํ
- ๊ณต์ ํด์๋ ์๋๋ ์์์ ๊ฒฝ์ฐ ๋ฐ๋์ ์ฑ๋ฆฝํด์ผ ํจ
- ํ๋ก์ธ์ค๊ฐ ์์์ ์์ฒญํ ๋ ๋ค๋ฅธ ์ด๋ค ์์๋ ๊ฐ์ง๊ณ ์์ง ์์์ผ ํ๋ค.
- ๋ฐฉ๋ฒ 1. ํ๋ก์ธ์ค ์์ ์ ๋ชจ๋ ํ์ํ ์์์ ํ ๋น๋ฐ๊ฒ ํ๋ ๋ฐฉ๋ฒ
- ๋ฐฉ๋ฒ 2. ์์์ด ํ์ํ ๊ฒฝ์ฐ ๋ณด์ ์์์ ๋ชจ๋ ๋๊ณ ๋ค์ ์์ฒญ
- process๊ฐ ์ด๋ค ์์์ ๊ธฐ๋ค๋ ค์ผ ํ๋ ๊ฒฝ์ฐ ์ด๋ฏธ ๋ณด์ ํ ์์์ด ์ ์ ๋จ
- ๋ชจ๋ ํ์ํ ์์์ ์ป์ ์ ์์ ๋ ๊ทธ ํ๋ก์ธ์ค๋ ๋ค์ ์์๋๋ค.
- State๋ฅผ ์ฝ๊ฒ saveํ๊ณ restoreํ ์ ์๋ ์์์์ ์ฃผ๋ก ์ฌ์ฉ (CPU, memory)
- ๋ชจ๋ ์์ ์ ํ์ ํ ๋น ์์๋ฅผ ์ ํ์ฌ ์ ํด์ง ์์๋๋ก๋ง ์์ ํ ๋น
- ์๋ฅผ ๋ค์ด ์์๊ฐ 3์ธ ์์ R[i]๋ฅผ ๋ณด์ ์ค์ธ ํ๋ก์ธ์ค๊ฐ ์์๊ฐ 1์ธ ์์R[j]๋ฅผ ํ ๋น๋ฐ๊ธฐ ์ํด์๋ ์ฐ์ R[i]๋ฅผ release ํด์ผํ๋ค.
Utilication ์ ํ, throughput ๊ฐ์, starvation ๋ฌธ์
- ์์ ์์ฒญ์ ๋ํ ๋ถ๊ฐ์ ๋ณด๋ฅผ ์ด์ฉํด์ ์์ ํ ๋น์ด deadlock์ผ๋ก ๋ถํฐ ์์ (safe)ํ์ง๋ฅผ ๋์ ์ผ๋ก ์กฐ์ฌํด์ ์์ ํ ๊ฒฝ์ฐ์๋ง ํ ๋น
- ๊ฐ์ฅ ๋จ์ํ๊ณ ์ผ๋ฐ์ ์ธ ๋ชจ๋ธ์ ํ๋ก์ธ์ค๋ค์ด ํ์๋ก ํ๋ ๊ฐ ์์๋ณ ์ต๋ ์ฌ์ฉ๋์ ๋ฏธ๋ฆฌ ์ ์ธํ๋๋ก ํ๋ ๋ฐฉ๋ฒ์
- ์์คํ ๋ด์ ํ๋ก์ธ์ค๋ค์ ๋ํ safe sequence๊ฐ ์กด์ฌํ๋ ์ํ
- ํ๋ก์ธ์ค์ sequence <P[1], P[2], ... P[n]>์ด safeํ๋ ค๋ฉด P[i] (1<=i<=n)์ ์์ ์์ฒญ์ด "๊ฐ์ฉ ์์ + ๋ชจ๋ Pj์ ๋ณด์ ์์"์ ์ํด ์ถฉ์กฑ๋์ด์ผ ํจ
- ์กฐ๊ฑด์ ๋ง์กฑํ๋ฉด ๋ค์ ๋ฐฉ๋ฒ์ผ๋ก ๋ชจ๋ ํ๋ก์ธ์ค์ ์ํ์ ๋ณด์ฅ
- P[i]์ ์์ ์์ฒญ์ด ์ฆ์ ์ถฉ์กฑ๋ ์ ์์ผ๋ฉด ๋ชจ๋ Pj๊ฐ ์ข ๋ฃ๋ ๋๊น์ง ๊ธฐ๋ค๋ฆฐ๋ค.
- P[i-1]์ด ์ข ๋ฃ๋๋ฉด P[i]์ ์์ ์์ฒญ์ ๋ง์กฑ์์ผ ์ํํ๋ค.
- no deadlock
- possibillity of deadlock
- ์์คํ ์ด unsafe state์ ๋ค์ด๊ฐ์ง ์๋ ๊ฒ์ ๋ณด์ฅ
- 2๊ฐ์ง ๊ฒฝ์ฐ์ avoidance ์๊ณ ๋ฆฌ์ฆ
- Single instance per resource types
- Resource Allocation Graph algorithm ์ฌ์ฉ
- Multiple instances per resource types
- Banker's Algorithm ์ฌ์ฉ
- Single instance per resource types
- ๋ชจ๋ ํ๋ก์ธ์ค๋ ์์์ ์ต๋ ์ฌ์ฉ๋์ ๋ฏธ๋ฆฌ ๋ช ์
- ํ๋ก์ธ์ค๊ฐ ์์ฒญ ์์์ ๋ชจ๋ ํ ๋น๋ฐ์ ๊ฒฝ์ฐ ์ ํ ์๊ฐ ์์ ์ด๋ค ์์์ ๋ค์ ๋ฐ๋ฉํ๋ค.
- ๊ธฐ๋ณธ ๊ฐ๋ : ์์์์ฒญ์ safe ์ํ๋ฅผ ์ ์งํ ๊ฒฝ์ฐ์๋ง ํ ๋น
- ์ด ์์ฒญ ์์์ ์๊ฐ ๊ฐ์ฉ ์์ ์๋ณด๋ค ์ ์ ํ๋ก์ธ์ค๋ฅผ ์ ํ (๊ทธ๋ฐ ํ๋ก์ธ์ค๊ฐ ์์ผ๋ฉด unsafe ์ํ)
- ๊ทธ๋ฐ ํ๋ก์ธ์ค๊ฐ ์์ผ๋ฉด ๊ทธ ํ๋ก์ธ์ค์๊ฒ ์์์ ํ ๋น
- ํ ๋น๋ฐ์ ํ๋ก์ธ์ค๊ฐ ์ข ๋ฃ๋๋ฉด ๋ชจ๋ ์์์ ๋ฐ๋ฉ
- ๋ชจ๋ ํ๋ก์ธ์ค๊ฐ ์ข ๋ฃ๋ ๋๊น์ง ์ด๋ฌํ ๊ณผ์ ๋ฐ๋ณต
Allocation | Max | Available | Need (Max - Allocation) | |
---|---|---|---|---|
A B C | A B C | A B C | A B C | |
P[0] | 0 1 0 | 7 5 3 | 3 3 2 | 7 4 3 |
P[1] | 2 0 0 | 3 2 2 | 1 2 2 | |
P[2] | 3 0 2 | 9 0 2 | 6 0 0 | |
P[3] | 2 1 1 | 2 2 2 | 0 1 1 | |
P[4] | 0 0 2 | 4 3 3 | 4 3 1 |
- sequence < P[1], P[3], P[4], P[2],P[0]>๊ฐ ์กด์ฌํ๋ฏ๋ก ์์คํ ์ safe state
- Abort all deadlocked processes
- Abort one processes at a time until the deadlock cycle is eliminated
- ๋น์ฉ์ ์ต์ํํ victim์ ์ ์
- safe state๋ก rollbackํ์ฌ process๋ฅผ restart
- Starvation ๋ฌธ์
- ๋์ผํ ํ๋ก์ธ์ค๊ฐ ๊ณ์ํด์ victim์ผ๋ก ์ ์ ๋๋ ๊ฒฝ์ฐ
- cost factor์ rollback ํ์๋ ๊ฐ์ด ๊ณ ๋ ค
- Deadlock์ด ๋งค์ฐ ๋๋ฌผ๊ฒ ๋ฐ์ํ๋ฏ๋ก deadlock์ ๋ํ ์กฐ์น ์์ฒด๊ฐ ๋ ํฐ overhead์ผ ์ ์์
- ๋ง์ฝ, ์์คํ ์ deadlock์ด ๋ฐ์ํ ๊ฒฝ์ฐ ์์คํ ์ด ๋น์ ์์ ์ผ๋ก ์๋ํ๋ ๊ฒ์ ๋๋ ํ ์ง์ process๋ฅผ ์ฃฝ์ด๋ ๋ฑ์ ๋ฐฉ๋ฒ์ผ๋ก ๋์ฒ
- UNIX, Window ๋ฑ ๋๋ถ๋ถ์ ๋ฒ์ฉ OS๊ฐ ์ฑํ
- ํ๋ก์ธ์ค๋ง๋ค ๋ ๋ฆฝ์ ์ผ๋ก ๊ฐ์ง๋ ์ฃผ์ ๊ณต๊ฐ
- ๊ฐ ํ๋ก์ธ์ค๋ง๋ค 0๋ฒ์ง๋ถํฐ ์์
- CPU๊ฐ ๋ณด๋ ์ฃผ์๋ logical address์
-
๋ฉ๋ชจ๋ฆฌ์ ์ค์ ์ฌ๋ผ๊ฐ๋ ์์น
-
์ฃผ์ ๋ฐ์ธ๋ฉ : ์ฃผ์๋ฅผ ๊ฒฐ์ ํ๋ ๊ฒ
- Symbolic Address -> Logical Address -> Physical address (์ด ์์ ์ ์ธ์ ?, next page)
- ๋ฌผ๋ฆฌ์ ๋ฉ๋ชจ๋ฆฌ ์ฃผ์(physical address)๊ฐ ์ปดํ์ผ ์ ์๋ ค์ง
- ์์ ์์น ๋ณ๊ฒฝ์ ์ฌ์ปดํ์ผ
- ์ปดํ์ผ๋ฌ๋ ์ ๋ ์ฝ๋(absolute code) ์์ฑ
- Loader์ ์ฑ ์ํ์ ๋ฌผ๋ฆฌ์ ๋ฉ๋ชจ๋ฆฌ ์ฃผ์ ๋ถ์ฌ
- ์ปดํ์ผ๋ฌ๊ฐ ์ฌ๋ฐฐ์น๊ฐ๋ฅ์ฝ๋(relocatable code)๋ฅผ ์์ฑํ ๊ฒฝ์ฐ ๊ฐ๋ฅ
- ์ํ์ด ์์๋ ์ดํ์๋ ํ๋ก์ธ์ค์ ๋ฉ๋ชจ๋ฆฌ ์ ์์น๋ฅผ ์ฎ๊ธธ ์ ์์
- CPU๊ฐ ์ฃผ์๋ฅผ ์ฐธ์กฐํ ๋๋ง๋ค binding์ ์ ๊ฒ(address mapping table)
- ํ๋์จ์ด์ ์ธ ์ง์์ด ํ์(e.g., base and limit registers, MMU)
- ์์ค์ฝ๋(Symbolic address) > ์ปดํ์ผ > ์คํํ์ผ(Logical address) > ์คํ์์ > ๋ฌผ๋ฆฌ์ ๋ฉ๋ชจ๋ฆฌ(Physical address)
- ๋ฌผ๋ฆฌ์ ๋ฉ๋ชจ๋ฆฌ์ ๋ฐ์ธ๋ฉ ํ๋ ๋ฐฉ๋ฒ : (Compile time binding, Load time binding, Run time binding)
- logical address๋ฅผ physical address๋ก ๋งคํํด ์ฃผ๋ Hardware device
- ์ฌ์ฉ์ ํ๋ก์ธ์ค๊ฐ CPU์์ ์ํ๋๋ฉฐ ์์ฑํด๋ด๋ ๋ชจ๋ ์ฃผ์๊ฐ์ ๋ํด base register(=relocation register)์ ๊ฐ์ ๋ํ๋ค.
- logical address๋ง์ ๋ค๋ฃฌ๋ค.
- ์ค์ physical address๋ฅผ ๋ณผ ์ ์์ผ๋ฉฐ ์ ํ์๊ฐ ์๋ค.
- ์ด์์ฒด์ ๋ฐ ์ฌ์ฉ์ ํ๋ก์ธ์ค๊ฐ์ ๋ฉ๋ชจ๋ฆฌ ๋ณดํธ๋ฅผ ์ํด ์ฌ์ฉํ๋ ๋ ์ง์คํฐ
- Relocation register : ์ ๊ทผํ ์ ์๋ ๋ฌผ๋ฆฌ์ ๋ฉ๋ชจ๋ฆฌ ์ฃผ์์ ์ต์๊ฐ (=base register)
- Limit register : ๋ ผ๋ฆฌ์ ์ฃผ์์; ๋ฒ์
-
Dynamic Loading
-
Dynamic Linking
-
Overlays
-
Swapping
- ํ๋ก์ธ์ค ์ ์ฒด๋ฅผ ๋ฉ๋ชจ๋ฆฌ์ ๋ฏธ๋ฆฌ ๋ค ์ฌ๋ฆฌ๋ ๊ฒ์ด ์๋๋ผ ํด๋น ๋ฃจํด์ด ๋ถ๋ ค์ง ๋ ๋ฉ๋ชจ๋ฆฌ์ load ํ๋ ๊ฒ
-
memory utilization์ ํฅ์
-
๊ฐ๋์ ์ฌ์ฉ๋๋ ๋ง์ ์์ ์ฝ๋์ ๊ฒฝ์ฐ ์ ์ฉ
- ์ : ์ค๋ฅ ์ฒ๋ฆฌ ๋ฃจํด
-
์ด์์ฒด์ ์ ํน๋ณํ ์ง์ ์์ด ํ๋ก๊ทธ๋จ ์์ฒด์์ ๊ตฌํ ๊ฐ๋ฅ(OS๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด ์ง์ ๊ฐ๋ฅ)
-
Loading : ๋ฉ๋ชจ๋ฆฌ๋ก ์ฌ๋ฆฌ๋ ๊ฒ
- ๋ฉ๋ชจ๋ฆฌ์ ํ๋ก์ธ์ค์ ๋ถ๋ถ ์ค ์ค์ ํ์ํ ์ ๋ณด๋ง์ ์ฌ๋ฆผ
- ํ๋ก์ธ์ค์ ํฌ๊ธฐ๊ฐ ๋ฉ๋ชจ๋ฆฌ๋ณด๋ค ํด ๋ ์ ์ฉ
- ์ด์์ฒด์ ์ ์ง์์์ด ์ฌ์ฉ์์ ์ํด ๊ตฌํ
- ์์ ๊ณต๊ฐ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ ์ด์ฐฝ๊ธฐ ์์คํ
์์ ์์์
์ผ๋ก ํ๋ก๊ทธ๋๋จธ๊ฐ ๊ตฌํ
- Manual Overlay
- ํ๋ก๊ทธ๋๋ฐ์ด ๋งค์ฐ ๋ณต์ก
- Swapping
- ํ๋ก์ธ์ค๋ฅผ ์ผ์์ ์ผ๋ก ๋ฉ๋ชจ๋ฆฌ์์ backing store๋ก ์ซ์๋ด๋ ๊ฒ
- Backing store(=swap area)
- ๋์คํฌ
- ๋ง์ ์ฌ์ฉ์์ ํ๋ก์ธ์ค ์ด๋ฏธ์ง๋ฅผ ๋ด์ ๋งํผ ์ถฉ๋ถํ ๋น ๋ฅด๊ณ ํฐ ์ ์ฅ ๊ณต๊ฐ
- ๋์คํฌ
- Swap in / Swap out
- ์ผ๋ฐ์ ์ผ๋ก ์ค๊ธฐ ์ค์ผ์ค๋ฌ(swapper)์ ์ํด swap out ์ํฌ ํ๋ก์ธ์ค ์ ์
- priority-based CPU scheduling algorithm
- priority๊ฐ ๋ฎ์ ํ๋ก์ธ์ค๋ฅผ swapped out ์ํด
- priority๊ฐ ๋์ ํ๋ก์ธ์ค๋ฅผ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ ค ๋์
- Compile time ํน์ load time binding์์๋ ์๋ ๋ฉ๋ชจ๋ฆฌ ์์น๋ก swap in ํด์ผํจ
- Execution time binding์์๋ ์ถํ ๋น ๋ฉ๋ชจ๋ฆฌ ์์ญ ์๋ฌด ๊ณณ์๋ ์ฌ๋ฆด ์ ์์
- swap time์ ๋๋ถ๋ถ transfer time(swap๋๋ ์์ ๋น๋กํ๋ ์๊ฐ)์
- Linking์ ์คํ ์๊ฐ(execution time)๊น์ง ๋ฏธ๋ฃจ๋ ๊ธฐ๋ฒ
- Static linking
- ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ํ๋ก๊ทธ๋จ์ ์คํ ํ์ผ ์ฝ๋์ ํฌํจ๋จ
- ์คํ ํ์ผ์ ํฌ๊ธฐ๊ฐ ์ปค์ง
- ๋์ผํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ฐ๊ฐ์ ํ๋ก์ธ์ค๊ฐ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฆฌ๋ฏ๋ก ๋ฉ๋ชจ๋ฆฌ ๋ญ๋น(eg. printf ํจ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฝ๋)
- Dynamic linking
- ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์คํ์ ์ฐ๊ฒฐ(link)๋จ
- ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํธ์ถ ๋ถ๋ถ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฃจํด์ ์์น๋ฅผ ์ฐพ๊ธฐ ์ํ stub์ด๋ผ๋ ์์ ์ฝ๋๋ฅผ ๋
- ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์ด๋ฏธ ๋ฉ๋ชจ๋ฆฌ์ ์์ผ๋ฉด ๊ทธ ๋ฃจํด์ ์ฃผ์๋ก ๊ฐ๊ณ ์์ผ๋ฉด ๋์คํฌ์์ ์ฝ์ด์ด
- ์ด์์ฒด์ ์ ๋์์ด ํ์
-
๋ฉ๋ชจ๋ฆฌ๋ ์ผ๋ฐ์ ์ผ๋ก ๋ ์์ญ์ผ๋ก ๋๋์ด ์ฌ์ฉ
- OS ์์ฃผ ์์ญ
- interrupt vector์ ํจ๊ป ๋ฎ์ ์ฃผ์ ์์ญ ์ฌ์ฉ
- ์ฌ์ฉ์ ํ๋ก์ธ์ค ์์ญ
- ๋์ ์ฃผ์ ์์ญ ์ฌ์ฉ
- OS ์์ฃผ ์์ญ
-
์ฌ์ฉ์ ํ๋ก์ธ์ค ์์ญ์ ํ ๋น ๋ฐฉ๋ฒ
- Contiguous allocation
- ๊ฐ๊ฐ์ ํ๋ก์ธ์ค๊ฐ ๋ฉ๋ชจ๋ฆฌ์ ์ฐ์์ ์ธ ๊ณต๊ฐ์ ์ ์ฌ๋๋๋ก ํ๋ ๊ฒ
- Fixed partition allocation
- Variable partition allocation
- ๊ฐ๊ฐ์ ํ๋ก์ธ์ค๊ฐ ๋ฉ๋ชจ๋ฆฌ์ ์ฐ์์ ์ธ ๊ณต๊ฐ์ ์ ์ฌ๋๋๋ก ํ๋ ๊ฒ
- Noncontiguous allocation
- ํ๋์ ํ๋ก์ธ์ค๊ฐ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฌ ์์ญ์ ๋ถ์ฐ๋์ด ์ฌ๋ผ๊ฐ ์ ์์
- Paging
- Segmentation
- Paged Segmentation
- ํ๋์ ํ๋ก์ธ์ค๊ฐ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฌ ์์ญ์ ๋ถ์ฐ๋์ด ์ฌ๋ผ๊ฐ ์ ์์
- Contiguous allocation
-
Contiguous allocation
-
๊ณ ์ ๋ถํ (Fixed partition) ๋ฐฉ์
- ๋ฌผ๋ฆฌ์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋ช ๊ฐ์ ์๊ตฌ์ ๋ถํ (partition)๋ก ๋๋
- ๋ถํ ์ ํฌ๊ธฐ๊ฐ ๋ชจ๋ ๋์ผํ ๋ฐฉ์๊ณผ ์๋ก ๋ค๋ฅธ ๋ฐฉ์์ด ์กด์ฌ
- ๋ถํ ๋น ํ๋์ ํ๋ก๊ทธ๋จ ์ ์ฌ
- ์ตํต์ฑ์ด ์์
- ๋์์ ๋ฉ๋ชจ๋ฆฌ์ load๋๋ ํ๋ก๊ทธ๋จ์ ์๊ฐ ๊ณ ์ ๋จ
- ์ต๋ ์ํ ๊ฐ๋ฅ ํ๋ก๊ทธ๋จ ํฌ๊ธฐ ์ ํ
- Internal fragmentation ๋ฐ์(external fragmentation๋ ๋ฐ์)
-
๊ฐ๋ณ๋ถํ (Variable partition) ๋ฐฉ์
- ํ๋ก๊ทธ๋จ์ ํฌ๊ธฐ๋ฅผ ๊ณ ๋ คํด์ ํ ๋น
- ๋ถํ ์ ํฌ๊ธฐ, ๊ฐ์๊ฐ ๋์ ์ผ๋ก ๋ณํจ
- ๊ธฐ์ ์ ๊ด๋ฆฌ ๊ธฐ๋ฒ ํ์
- External fragmentation ๋ฐ์
-
- Hole
- ๊ฐ์ฉ ๋ฉ๋ชจ๋ฆฌ ๊ณต๊ฐ
- ๋ค์ํ ํฌ๊ธฐ์ hole๋ค์ด ๋ฉ๋ชจ๋ฆฌ ์ฌ๋ฌ ๊ณณ์ ํฉ์ด์ ธ ์์
- ํ๋ก์ธ์ค๊ฐ ๋์ฐฉํ๋ฉด ์์ฉ๊ฐ๋ฅํ hole์ ํ ๋น
- ์ด์์ฒด์ ๋ ๋ค์์ ์ ๋ณด๋ฅผ ์ ์ง
- a) ํ ๋น ๊ณต๊ฐ
- b) ๊ฐ์ฉ ๊ณต๊ฐ(hole)
-
๊ฐ๋ณ ๋ถํ ๋ฐฉ์์์ size n์ธ ์์ฒญ์ ๋ง์กฑํ๋ ๊ฐ์ฅ ์ ์ ํ hole์ ์ฐพ๋ ๋ฌธ์
- First-fit
- Size๊ฐ n ์ด์์ธ ๊ฒ ์ค ์ต์ด๋ก ์ฐพ์์ง๋ hole์ ํ ๋น
- Best-fit
- Size๊ฐ n ์ด์์ธ ๊ฐ์ฅ ์์ hole์ ์ฐพ์์ ํ ๋น
- Hole๋ค์ ๋ฆฌ์คํธ๊ฐ ํฌ๊ธฐ์์ผ๋ก ์ ๋ ฌ๋์ง ์์ ๊ฒฝ์ฐ ๋ชจ๋ hole์ ๋ฆฌ์คํธ๋ฅผ ํ์ํด์ผํจ
- ๋ง์ ์์ ์์ฃผ ์์ hole๋ค์ด ์์ฑ๋จ
- Worst-fit
- ๊ฐ์ฅ ํฐ hole์ ํ ๋น
- ์ญ์ ๋ชจ๋ ๋ฆฌ์คํธ๋ฅผ ํ์ํด์ผ ํจ
- ์๋์ ์ผ๋ก ์์ฃผ ํฐ hole๋ค์ด ์์ฑ๋จ
- First-fit
-
First-fit๊ณผ best-fit์ด worst-fit๋ณด๋ค ์๋์ ๊ณต๊ฐ ์ด์ฉ๋ฅ ์ธก๋ฉด์์ ํจ๊ณผ์ ์ธ ๊ฒ์ผ๋ก ์๋ ค์ง(์คํ์ ์ธ ๊ฒฐ๊ณผ)
- compaction
- external fragmentation ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ํ ๊ฐ์ง ๋ฐฉ๋ฒ
- ์ฌ์ฉ ์ค์ธ ๋ฉ๋ชจ๋ฆฌ ์์ญ์ ํ๊ตฐ๋ฐ๋ก ๋ชฐ๊ณ hole๋ค์ ๋ค๋ฅธ ํ ๊ณณ์ผ๋ก ๋ชฐ์ ํฐ block์ ๋ง๋๋ ๊ฒ
- ๋งค์ฐ ๋น์ฉ์ด ๋ง์ด ๋๋ ๋ฐฉ๋ฒ์
- ์ต์ํ์ ๋ฉ๋ชจ๋ฆฌ ์ด๋์ผ๋ก compactioํ๋ ๋ฐฉ๋ฒ(๋งค์ฐ ๋ณต์กํ ๋ฌธ์ )
- Compaction์ ํ๋ก์ธ์ค์ ์ฃผ์๊ฐ ์คํ ์๊ฐ์ ๋์ ์ผ๋ก ์ฌ๋ฐฐ์น ๊ฐ๋ฅํ ๊ฒฝ์ฐ์๋ง ์ํ๋ ์ ์๋ค.
- Page table์ main memory์ ์์ฃผ
- Page-table base register (PTBR)๊ฐ page table์ ๊ฐ๋ฆฌํด
- Page-table length register (PTLR)๊ฐ ํ ์ด๋ธ ํฌ๊ธฐ๋ฅผ ๋ณด๊ด
- ๋ชจ๋ ๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ ์ฐ์ฐ์๋ 2๋ฒ์ memory access ํ์
- page table ์ ๊ทผ 1๋ฒ, ์ค์ data/instruction ์ ๊ทผ 1๋ฒ
- ์๋ ํฅ์์ ์ํด associative register ํน์ translation look-aside buffer (TLB)๋ผ ๋ถ๋ฆฌ๋ ๊ณ ์์ lookup hardware cache ์ฌ์ฉ
- Associative registers (TLB) : parallel search๊ฐ ๊ฐ๋ฅ
- TLB์๋ page table ์ค ์ผ๋ถ๋ง ์กด์ฌ.
- Address translation
- page table ์ค ์ผ๋ถ๊ฐ associative register์ ๋ณด๊ด๋์ด์์
- ๋ง์ฝ ํด๋น page #๊ฐ associative register์ ์๋ ๊ฒฝ์ฐ ๊ณง๋ฐ๋ก frame#์ ์ป์
- TLB๋ context switch ๋ flush (remove old entries)
- Associative register lookup time = ์ก์ค๋ก
- memory cycle time = 1
- Hit ratio = ์ํ
- associatvie register์์ ์ฐพ์์ง๋ ๋น์จ
- Effective Access Time(EAT)
- ํ์ฌ์ ์ปดํจํฐ๋ address space๊ฐ ๋งค์ฐ ํฐ ํ๋ก๊ทธ๋จ ์ง์
- 32 bit address ์ฌ์ฉ์ : 2^^32(4G)์ ์ฃผ์ ๊ณต๊ฐ
- page size๊ฐ 4K์ 1M๊ฐ์ page table entry ํ์
- ๊ฐ page entry๊ฐ 4B์ ํ๋ก์ธ์ค๋น 4M์ page table ํ์
- ๊ทธ๋ฌ๋, ๋๋ถ๋ถ์ ํ๋ก๊ทธ๋จ์ 4G์ ์ฃผ์ ๊ณต๊ฐ ์ค ์ง๊ทนํ ์ผ๋ถ๋ถ๋ง ์ฌ์ฉํ๋ฏ๋ก page table ๊ณต๊ฐ์ด ์ฌํ๊ฒ ๋ญ๋น๋จ
- page table ์์ฒด๋ฅผ page๋ก ๊ตฌ์ฑ
- ์ฌ์ฉ๋์ง ์๋ ์ฃผ์ ๊ณต๊ฐ์ ๋ํ outer page table์ ์ํธ๋ฆฌ ๊ฐ์ NULL(๋์ํ๋ inner page table์ด ์์)
- 32 bit address ์ฌ์ฉ์ : 2^^32(4G)์ ์ฃผ์ ๊ณต๊ฐ
-
logical address (on 32-bit machine with 4K page size)์ ๊ตฌ์ฑ
- 20 bit์ page number
- 12 bit์ page offset
-
page table ์์ฒด๊ฐ page๋ก ๊ตฌ์ฑ๋๊ธฐ ๋๋ฌธ์ page number๋ ๋ค์๊ณผ ๊ฐ์ด ๋๋๋ค.
- 10-bit์ page number.
- 10-bit์ page offset.
-
๋ฐ๋ผ์ logical address๋ ๋ค์๊ณผ ๊ฐ๋ค.
page number page offset p1 p2 d 10 10 12
- P1์ outer page table์ index์ด๊ณ
- P2๋ outer page table์ page์์์ ๋ณ์(displacement)
- Address space๊ฐ ๋ ์ปค์ง๋ฉด ๋ค๋จ๊ณ ํ์ด์ง ํ ์ด๋ธ ํ์
- ๊ฐ ๋จ๊ณ์ ํ์ด์ง ํ ์ด๋ธ์ด ๋ฉ๋ชจ๋ฆฌ์ ์กด์ฌํ๋ฏ๋ก logical address์ physical address ๋ณํ์ ๋ ๋ง์ ๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ ํ์
- TLB๋ฅผ ํตํด ๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ ์๊ฐ์ ์ค์ผ ์ ์์.
- 4๋จ๊ณ ํ์ด์ง ํ
์ด๋ธ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ
- ๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ ์๊ฐ์ด 100ns, TLB ์ ๊ทผ ์๊ฐ์ด 20ns์ด๊ณ
- TLB hit ratio๊ฐ 98%์ธ ๊ฒฝ์ฐ
- effective memory access time = 0.98 _ 120 + 0.02 _ 520 = 128 nanoseconds.
- ๊ฒฐ๊ณผ์ ์ผ๋ก ์ฃผ์๋ณํ์ ์ํด 28ns๋ง ์์
-
Page table์ ๊ฐ entry๋ง๋ค ์๋์ bit๋ฅผ ๋๋ค.
-
Protection bit
- page์ ๋ํ ์ ๊ทผ ๊ถํ (read/write/read-only)
-
Valid-invalid bit
-
"valid"๋ ํด๋น ์ฃผ์์ frame์ ๊ทธ ํ๋ก์ธ์ค๋ฅผ ๊ตฌ์ฑํ๋ ์ ํจํ ๋ด์ฉ์ด ์์์ ๋ปํจ (์ ๊ทผ ํ์ฉ)
-
"invalid"๋ ํด๋น ์ฃผ์์ frame์ ์ ํจํ ๋ด์ฉ์ด ์์*์ ๋ปํจ(์ ๊ทผ ๋ถํ)
-
"*" i) ํ๋ก์ธ์ค๊ฐ ๊ทธ ์ฃผ์ ๋ถ๋ถ์ ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ
-
"*" ii) ํด๋น ํ์ด์ง๊ฐ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ผ์ ์์ง ์๊ณ swap area์ ์๋ ๊ฒฝ์ฐ
-
-
-
page table์ด ๋งค์ฐ ํฐ ์ด์
- ๋ชจ๋ process๋ณ๋ก ๊ทธ logical address์ ๋์ํ๋ ๋ชจ๋ page์ ๋ํด page table entry๊ฐ ์กด์ฌ.
- ๋์ํ๋ page๊ฐ ๋ฉ๋ชจ๋ฆฌ์ ์๋ ์๋๋ ๊ฐ์ page table์๋ entry๋ก ์กด์ฌ
-
Inverted page table
- Page frame ํ๋๋น page table์ ํ๋์ entry๋ฅผ ๋ ๊ฒ (system-wide)
- ๊ฐ page table entry๋ ๊ฐ๊ฐ์ ๋ฌผ๋ฆฌ์ ๋ฉ๋ชจ๋ฆฌ์ page frame์ด ๋ด๊ณ ์๋ ๋ด์ฉ ํ์(process-id, process์ logical address)
- ๋จ์
- ํ ์ด๋ธ ์ ์ฒด๋ฅผ ํ์ํด์ผํจ
- ์กฐ์น
- associative register ์ฌ์ฉ (expensive)
- Shared code
- Re-entrant Code (=Pure code)
- read-only๋ก ํ์ฌ ํ๋ก์ธ์ค ๊ฐ์ ํ๋์ code๋ง ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฆผ(eg, text editors, compilers, window systems)
- Shared code๋ ๋ชจ๋ ํ๋ก์ธ์ค์ logical address space์์ ๋์ผํ ์์น ์์ด์ผํจ
- Private code and data
- ๊ฐ ํ๋ก์ธ์ค๋ค์ ๋ ์์ ์ผ๋ก ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฆผ
- Private data๋ logical address space์ ์๋ฌด ๊ณณ์ ์๋ ๋ฌด๋ฐฉ
- ํ๋ก๊ทธ๋จ์ ์๋ฏธ ๋จ์์ธ ์ฌ๋ฌ ๊ฐ์ segment๋ก ๊ตฌ์ฑ
- ์๊ฒ๋ ํ๋ก๊ทธ๋จ์ ๊ตฌ์ฑํ๋ ํจ์ ํ๋ํ๋๋ฅผ ์ธ๊ทธ๋จผํธ๋ก ์ ์
- ํฌ๊ฒ๋ ํ๋ก๊ทธ๋จ ์ ์ฒด๋ฅผ ํ๋์ ์ธ๊ทธ๋จผํธ๋ก ์ ์ ๊ฐ๋ฅ
- ์ผ๋ฐ์ ์ผ๋ก๋ code, data, stack ๋ถ๋ถ์ด ํ๋์ฉ์ ์ธ๊ทธ๋จผํธ๋ก ์ ์๋จ
- Segment๋ ๋ค์๊ณผ ๊ฐ์ logical unit๋ค์
main(),
function,
global variables,
stack,
symbol table, arrays
-
Logical address๋ ๋ค์์ ๋ ๊ฐ์ง๋ก ๊ตฌ์ฑ
- <segment-number, offset>
-
Segment table
- each table entry has:
- base - starting physical address of the segment
- limit - length of the segment
- each table entry has:
-
Segment-table base register(STBR)
- ๋ฌผ๋ฆฌ์ ๋ฉ๋ชจ๋ฆฌ์์์ segment table์ ์์น
-
Segment-table length register(STLR)
- ํ๋ก๊ทธ๋จ์ด ์ฌ์ฉํ๋ segment์ ์
- segment number s is legal if s < STLR
- ํ๋ก๊ทธ๋จ์ด ์ฌ์ฉํ๋ segment์ ์
- Protection
- ๊ฐ ์ธ๊ทธ๋จผํธ ๋ณ๋ก protection bit๊ฐ ์์
- Each entry:
- Valid bit = 0 > illegal segment
- Read/Write/Execution ๊ถํ bit
- Sharing
- shared segment
- same segment number
- segment๋ ์๋ฏธ๋จ์์ด๊ธฐ ๋๋ฌธ์ ๊ณต์ (sharing)๊ณผ ๋ณด์(protection)์ ์์ด paging๋ณด๋ค ํจ์ฌ ํจ๊ณผ์ ์ด๋ค.
- Allocation
- first fit / best fit
- external fragmentation ๋ฐ์
- segment์ ๊ธธ์ด๊ฐ ๋์ผํ์ง ์์ผ๋ฏ๋ก ๊ฐ๋ณ๋ถํ ๋ฐฉ์์์์ ๋์ผํ ๋ฌธ์ ์ ๋ค์ด ๋ฐ์
- pure segmentation๊ณผ์ ์ฐจ์ด์
- segment-table entry๊ฐ segment์ base address๋ฅผ ๊ฐ์ง๊ณ ์๋ ๊ฒ์ด ์๋๋ผ segment๋ฅผ ๊ตฌ์ฑํ๋ page table์ base address๋ฅผ ๊ฐ์ง๊ณ ์์
- ์ค์ ๋ก ํ์ํ ๋ page๋ฅผ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฆฌ๋ ๊ฒ
- I/O ์์ ๊ฐ์
- Memory ์ฌ์ฉ๋ ๊ฐ์
- ๋น ๋ฅธ ์๋ต ์๊ฐ
- ๋ ๋ง์ ์ฌ์ฉ์ ์์ฉ
- Valid / Invalid bit์ ์ฌ์ฉ
- Invalid์ ์๋ฏธ
- ์ฌ์ฉ๋์ง ์์ ์ฃผ์ ์์ญ์ธ ๊ฒฝ์ฐ
- ํ์ด์ง๊ฐ ๋ฌผ๋ฆฌ์ ๋ฉ๋ชจ๋ฆฌ์ ์๋ ๊ฒฝ์ฐ
- ์ฒ์์๋ ๋ชจ๋ page entry๊ฐ invalid๋ก ์ด๊ธฐํ
- address translation ์์ invalid bit์ด set๋์ด ์๋ค๋ฉด >> "page fault"
- Invalid์ ์๋ฏธ
- invalid page๋ฅผ ์ ๊ทผํ๋ฉด MMU๊ฐ trap์ ๋ฐ์์ํด(page fault trap)
- Kernel mode๋ก ๋ค์ด๊ฐ์ page fault handler๊ฐ invoke๋จ
- ๋ค์๊ณผ ๊ฐ์ ์์๋ก page fault๋ฅผ ์ฒ๋ฆฌํ๋ค.
- Invalid reference ? (eg. bad address, protection violation) => abort process.
- Get an empty page frame(์์ผ๋ฉด ๋บ์ด์จ๋ค: replace)
- ํด๋น ํ์ด์ง๋ฅผ disk์์ memory๋ก ์ฝ์ด์จ๋ค.
- 3-1. disk I/O๊ฐ ๋๋๊ธฐ๊น์ง ์ด ํ๋ก์ธ์ค๋ CPU๋ฅผ preempt ๋นํจ (block)
- 3-2. Disk read๊ฐ ๋๋๋ฉด page tables entry ๊ธฐ๋ก, valid/invalid bit = "valid"
- 3-3. ready queue์ process๋ฅผ insert -> dispatch later
- ์ด ํ๋ก์ธ์ค๊ฐ CPU๋ฅผ ์ก๊ณ ๋ค์ running
- ์๊น ์ค๋จ๋์๋ instruction์ ์ฌ๊ฐ
- Page Fault Rate 0 <= p <= 1.0
- if p = 0, no page faults
- if p = 1, every reference is a fault
- Effective Access Time
- =(1-p) * memory access
- +p (OS & HW page fault overhead)
- +[swap page out if needed]
-
- swap page in
-
- OS & HW restart overhead
-
Page replacement
- ์ด๋ค frame์ ๋นผ์์์ฌ์ง ๊ฒฐ์ ํด์ผ ํจ
- ๊ณง๋ฐ๋ก ์ฌ์ฉ๋์ง ์์ page๋ฅผ ์ซ์๋ด๋ ๊ฒ์ด ์ข์
- ๋์ผํ ํ์ด์ง๊ฐ ์ฌ๋ฌ ๋ฒ ๋ฉ๋ชจ๋ฆฌ์์ ์ซ๊ฒจ๋ฌ๋ค๊ฐ ๋ค์ ๋ค์ด์ฌ ์ ์์
-
Replacement Algorithm
- page-fault rate๋ฅผ ์ต์ํํ๋ ๊ฒ์ด ๋ชฉํ
- ์๊ณ ๋ฆฌ์ฆ์ ํ๊ฐ
- ์ฃผ์ด์ง page reference string์ ๋ํด page fault๋ฅผ ์ผ๋ง๋ ๋ด๋์ง ์กฐ์ฌ
- reference string์ ์
- 1,2,3,4,1,2,5,1,2,3,4,5.
- swap out victim page
- change to invalid (page table[frame, valid-invalid bit])
- swap desired page in
- reset page table for new page
- MIN (OPT) : ๊ฐ์ฅ ๋จผ ๋ฏธ๋์ ์ฐธ์กฐ๋๋ page๋ฅผ replace
- 4 frames example
- 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
- ๋ฏธ๋์ ์ฐธ์กฐ๋ฅผ ์ด๋ป๊ฒ ์๋๊ฐ ?
- Offline algorithm
- ๋ค๋ฅธ ์๊ณ ๋ฆฌ์ฆ์ ์ฑ๋ฅ์ ๋ํ upper bound ์ ๊ณต
- Belady's optimal algorithm, MIN, OPT๋ฑ์ผ๋ก ๋ถ๋ฆผ
-
FIFO : ๋จผ์ ๋ค์ด์จ ๊ฒ์ ๋จผ์ ๋ด์ซ์
- 3 page frames : 9 page faults
- 4 page frames : 10 page faults
-
FIFO Anomaly (Belady's Anomaly)
- more frames => less page faults
- LRU : ๊ฐ์ฅ ์ค๋ ์ ์ ์ฐธ์กฐ๋ ๊ฒ์ ์ง์
- LFU : ์ฐธ์กฐ ํ์(reference count)๊ฐ ๊ฐ์ฅ ์ ์ ํ์ด์ง๋ฅผ ์ง์
- ์ต์ ์ฐธ์กฐ ํ์์ธ page๊ฐ ์ฌ๋ฟ ์๋ ๊ฒฝ์ฐ
- LFU ์๊ณ ๋ฆฌ์ฆ ์์ฒด์์๋ ์ฌ๋ฌ page ์ค ์์๋ก ์ ์ ํ๋ค.
- ์ฑ๋ฅ ํฅ์์ ์ํด ๊ฐ์ฅ ์ค๋์ ์ ์ฐธ์กฐ๋ page๋ฅผ ์ง์ฐ๊ฒ ๊ตฌํ ํ ์๋ ์๋ค.
- ์ฅ๋จ์
- LRU์ฒ๋ผ ์ง์ ์ฐธ์กฐ ์์ ๋ง ๋ณด๋ ๊ฒ์ด ์๋๋ผ ์ฅ๊ธฐ์ ์ธ ์๊ฐ ๊ท๋ชจ๋ฅผ ๋ณด๊ธฐ ๋๋ฌธ์ page์ ์ธ๊ธฐ๋๋ฅผ ์ข ๋ ์ ํํ ๋ฐ์ํ ์ ์์
- ์ฐธ์กฐ ์์ ์ ์ต๊ทผ์ฑ์ ๋ฐ์ํ์ง ๋ชปํจ
- LRU๋ณด๋ค ๊ตฌํ์ด ๋ณต์กํจ
- ์ต์ ์ฐธ์กฐ ํ์์ธ page๊ฐ ์ฌ๋ฟ ์๋ ๊ฒฝ์ฐ
- LRU : O(1) complexity (LRU page ~ MRU page)
- ์ต์ LPU : O(log n) complexity (LFU page ~ MRU page) - mean heap
- ์ต์ LPU : O(n) complexity (LFU page ~ MRU page, ํ์ค๋ก ์ค ์ธ์ฐ๊ธฐ ํ ๋)
- ์บ์ ๊ธฐ๋ฒ
- ํ์ ๋ ๋น ๋ฅธ ๊ณต๊ฐ(=์บ์ฌ)์ ์์ฒญ๋ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํด ๋์๋ค๊ฐ ํ์ ์์ฒญ์ ์บ์ฌ๋ก๋ถํฐ ์ง์ ์๋น์คํ๋ ๋ฐฉ์
- paging system์ธ์๋ cache memory, buffer caching, Web caching ๋ฑ ๋ค์ํ ๋ถ์ผ์์ ์ฌ์ฉ
- ์บ์ฌ ์ด์์ ์๊ฐ ์ ์ฝ
- ๊ต์ฒด ์๊ณ ๋ฆฌ์ฆ์์ ์ญ์ ํ ํญ๋ชฉ์ ๊ฒฐ์ ํ๋ ์ผ์ ์ง๋์น๊ฒ ๋ง์ ์๊ฐ์ด ๊ฑธ๋ฆฌ๋ ๊ฒฝ์ฐ ์ค์ ์์คํ ์์ ์ฌ์ฉํ ์ ์์
- Buffer caching์ด๋ Web caching์ ๊ฒฝ์ฐ
- O(1)์์ O(log n) ์ ๋๊น์ง ํ์ฉ
- Paging system์ธ ๊ฒฝ์ฐ
- page fault์ธ ๊ฒฝ์ฐ์๋ง OS๊ฐ ๊ด์ฌํจ
- ํ์ด์ง๊ฐ ์ด๋ฏธ ๋ฉ๋ชจ๋ฆฌ์ ์กด์ฌํ๋ ๊ฒฝ์ฐ ์ฐธ์กฐ์๊ฐ๋ฑ์ ์ ๋ณด๋ฅผ OS๊ฐ ์ ์ ์์
- O(1)์ธ LRU์ list์กฐ์์กฐ์ฐจ ๋ถ๊ฐ๋ฅ
- Clock algorithm
- LRU์ ๊ทผ์ฌ(approximation) ์๊ณ ๋ฆฌ์ฆ
- ์ฌ๋ฌ ๋ช
์นญ์ผ๋ก ๋ถ๋ฆผ
- Second chance algorithm
- NUR(Not Used Recently) ๋๋ NRU(Not Recently Used)
- Reference bit์ ์ฌ์ฉํด์ ๊ต์ฒด ๋์ ํ์ด์ง ์ ์ (circular list)
- reference bit๊ฐ 0์ธ ๊ฒ์ ์ฐพ์ ๋๊น์ง ํฌ์ธํธ๋ฅผ ํ๋์ฉ ์์ผ๋ก ์ด๋
- ํฌ์ธํฐ ์ด๋ํ๋ ์ค์ reference bit 1์ ๋ชจ๋ 0์ผ๋ก ๋ฐ๊ฟ
- Reference bit์ด 0์ธ ๊ฒ์ ์ฐพ์ผ๋ฉด ๊ทธ ํ์ด์ง๋ฅผ ๊ต์ฒด
- ํ ๋ฐํด ๋๋์์์๋(=second chance) 0์ด๋ฉด ๊ทธ๋์๋ replace ๋นํจ
- ์์ฃผ ์ฌ์ฉ๋๋ ํ์ด์ง๋ผ๋ฉด second chance๊ฐ ์ฌ ๋ 1
- Clock algorithm์ ๊ฐ์
- reference bit๊ณผ modified bit (dirty bit)์ ํจ๊ป ์ฌ์ฉ
- referce bit = 1 : ์ต๊ทผ์ ์ฐธ์กฐ๋ ํ์ด์ง
- modified bit = 1 : ์ต๊ทผ์ ๋ณ๊ฒฝ๋ ํ์ด์ง(I/O๋ฅผ ๋๋ฐํ๋ ํ์ด์ง)
- Allocation problem : ๊ฐ process์ ์ผ๋ง๋งํผ์ page frame์ ํ ๋นํ ๊ฒ์ธ๊ฐ ?
- Allocation์ ํ์์ฑ :
- ๋ฉ๋ชจ๋ฆฌ ์ฐธ์กฐ ๋ช
๋ น์ด ์ํ์ ๋ช
๋ น์ด, ๋ฐ์ดํฐ ๋ฑ ์ฌ๋ฌ ํ์ด์ง ๋์ ์ฐธ์กฐ
- ๋ช ๋ น์ด ์ํ์ ์ํด ์ต์ํ ํ ๋น๋์ด์ผ ํ๋ frame์ ์๊ฐ ์์
- Loop๋ฅผ ๊ตฌ์ฑํ๋ page๋ค์ ํ๊บผ๋ฒ์ allocate ๋๋ ๊ฒ์ด ์ ๋ฆฌํจ
- ์ต์ํ์ allocation์ด ์์ผ๋ฉด ๋งค loop๋ง๋ค page fault
- ๋ฉ๋ชจ๋ฆฌ ์ฐธ์กฐ ๋ช
๋ น์ด ์ํ์ ๋ช
๋ น์ด, ๋ฐ์ดํฐ ๋ฑ ์ฌ๋ฌ ํ์ด์ง ๋์ ์ฐธ์กฐ
- Allocation Scheme
- Equal allocation : ๋ชจ๋ ํ๋ก์ธ์ค์ ๋๊ฐ์ ๊ฐฏ์ ํ ๋น
- Proportional allocation : ํ๋ก์ธ์ค ํฌ๊ธฐ์ ๋น๋กํ์ฌ ํ ๋น
- Priority allocation : ํ๋ก์ธ์ค์ priority์ ๋ฐ๋ผ ๋ค๋ฅด๊ฒ ํ ๋น
- Replace์ ๋ค๋ฅธ process์ ํ ๋น๋ frame์ ๋นผ์์ ์ฌ ์ ์๋ค.
- Process๋ณ ํ ๋น๋์ ์กฐ์ ํ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์
- FIFO, LRU, LFU ๋ฑ์ ์๊ณ ๋ฆฌ์ฆ์ global replacement๋ก ์ฌ์ฉ์์ ํด๋น
- Working set, PFF ์๊ณ ๋ฆฌ์ฆ ์ฌ์ฉ
- ์์ ์๊ฒ ํ ๋น๋ frame ๋ด์์๋ง replacement
- FIFO, LRU, LFU ๋ฑ์ ์๊ณ ๋ฆฌ์ฆ์ process๋ณ๋ก ์ด์์
- ํ๋ก์ธ์ค์ ์ํํ ์ํ์ ํ์ํ ์ต์ํ์ page frame ์๋ฅผ ํ ๋น ๋ฐ์ง ๋ชปํ ๊ฒฝ์ฐ ๋ฐ์
- Page fault rate์ด ๋งค์ฐ ๋์์ง
- CPU utilization์ด ๋์์ง
- OS๋ MPD (Multiprogramming degree)๋ฅผ ๋์ฌ์ผ ํ๋ค๊ณ ํ๋จ
- ๋ ๋ค๋ฅธ ํ๋ก์ธ์ค๊ฐ ์์คํ ์ ์ถ๊ฐ๋จ (higher MPD)
- ํ๋ก์ธ์ค ๋น ํ ๋น๋ frame์ ์๊ฐ ๋์ฑ ๊ฐ์
- ํ๋ก์ธ์ค๋ page์ swap in / swap out์ผ๋ก ๋งค์ฐ ๋ฐ์จ
- ๋๋ถ๋ถ์ ์๊ฐ์ CPU๋ ํ๊ฐํจ
- low throughput
- ํ๋ก์ธ์ค๋ ํน์ ์๊ฐ๋์ ์ผ์ ์ฅ์๋ง์ ์ง์ค์ ์ผ๋ก ์ฐธ์กฐํ๋ค.
- ์ง์ค์ ์ผ๋ก ์ฐธ์กฐ๋๋ ํด๋น page๋ค์ ์งํฉ์ locality set์ด๋ผ ํจ.
- Locality์ ๊ธฐ๋ฐํ์ฌ ํ๋ก์ธ์ค๊ฐ ์ผ์ ์๊ฐ๋์ ์ํํ๊ฒ ์ํ๋๊ธฐ ์ํด ํ๊บผ๋ฒ์ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ผ์ ์์ด์ผ ํ๋ page๋ค์ ์งํฉ์ Working Set์ด๋ผ ์ ์ํจ
- Working Set ๋ชจ๋ธ์์๋ process์ working set ์ ์ฒด๊ฐ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ผ์ ์์ด์ผ ์ํ๋๊ณ ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ ๋ชจ๋ frame์ ๋ฐ๋ฉํ ํ swap out (suspend)
- Thrashing์ ๋ฐฉ์งํจ
- Multiprogramming degree๋ฅผ ๊ฒฐ์ ํจ
- Working set์ ๊ฒฐ์
- Working set window๋ฅผ ํตํด ์์๋
- window size๊ฐ ๋ธํ์ธ ๊ฒฝ์ฐ
- ์๊ฐ t[i]์์์ working set WS (t[i])
- Time interval[t[i]-๋ธํ, t[i]] ์ฌ์ด์ ์ฐธ์กฐ๋ ์๋ก ๋ค๋ฅธ ํ์ด์ง๋ค์ ์งํฉ
- Working set์ ์ํ page๋ ๋ฉ๋ชจ๋ฆฌ์ ์ ์ง, ์ํ์ง ์์ ๊ฒ์ ๋ฒ๋ฆผ
- (์ฆ, ์ฐธ์กฐ๋ ํ ๋ธํ ์๊ฐ๋์ ํด๋น page๋ฅผ ๋ฉ๋ชจ๋ฆฌ์ ์ ์งํ ํ ๋ฒ๋ฆผ)
- ์๊ฐ t[i]์์์ working set WS (t[i])
- Process๋ค์ working set size์ ํฉ์ด page frame์ ์๋ณด๋ค ํฐ ๊ฒฝ์ฐ
- ์ผ๋ถ process๋ฅผ swap out์์ผ ๋จ์ process์ working set์ ์ฐ์ ์ ์ผ๋ก ์ถฉ์กฑ์์ผ ์ค๋ค. (MPD๋ฅผ ์ค์)
- Working set์ ๋ค ํ ๋นํ๊ณ ๋ page frame์ด ๋จ๋ ๊ฒฝ์ฐ
- Swap out ๋์๋ ํ๋ก์ธ์ค์๊ฒ working set์ ํ ๋น (MPD๋ฅผ ํค์)
- Working set์ ์ ๋๋ก ํ์งํ๊ธฐ ์ํด์๋ window size๋ฅผ ์ ๊ฒฐ์ ํด์ผ ํจ
- ๋ธํ ๊ฐ์ด ๋๋ฌด ์์ผ๋ฉด locality set์ ๋ชจ๋ ์์ฉํ์ง ๋ชปํ ์ฐ๋ ค
- ๋ธํ ๊ฐ์ด ํฌ๋ฉด ์ฌ๋ฌ ๊ท๋ชจ์ locality set ์์ฉ
- ๋ธํ๊ฐ์ด ๋ฌดํ๋๋ฉด ์ ์ฒด ํ๋ก๊ทธ๋จ์ ๊ตฌ์ฑํ๋ page๋ฅผ working set์ผ๋ก ๊ฐ์ฃผ
- page-fault rate์ ์ํ๊ฐ๊ณผ ํํ๊ฐ์ ๋๋ค.
- Page fault rate์ด ์ํ๊ฐ์ ๋์ผ๋ฉด frame์ ๋ ํ ๋นํ๋ค.
- Page fault rate์ด ํํ๊ฐ ์ดํ์ด๋ฉด ํ ๋น frame ์๋ฅผ ์ค์ธ๋ค.
- ๋น frame์ด ์์ผ๋ฉด ์ผ๋ถ ํ๋ก์ธ์ค๋ฅผ swap out
-
Page size๋ฅผ ๊ฐ์์ํค๋ฉด
-
ํ์ด์ง ์ ์ฆ๊ฐ
-
ํ์ด์ง ํ ์ด๋ธ ํฌ๊ธฐ ์ฆ๊ฐ
-
Internal fragmentation ๊ฐ์
-
Disk transfer์ ํจ์จ์ฑ ๊ฐ์
- Seek/rotation vs. transfer
-
ํ์ํ ์ ๋ณด๋ง ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ผ์ ๋ฉ๋ชจ๋ฆฌ ์ด์ฉ์ด ํจ์จ์
- Locality์ ํ์ฉ ์ธก๋ฉด์์๋ ์ข์ง ์์
-
-
Trend
- Larger page size
- "A named collection of related information"
- ์ผ๋ฐ์ ์ผ๋ก ๋นํ๋ฐ์ฑ์ ๋ณด์กฐ๊ธฐ์ต์ฅ์น์ ์ ์ฅ
- ์ด์์ฒด์ ๋ ๋ค์ํ ์ ์ฅ์ฅ์น๋ฅผ file์ด๋ผ๋ ๋์ผํ ๋ ผ๋ฆฌ์ ๋จ์๋ก ๋ณผ ์ ์๊ฒ ํด์ค
- Operation
- create, read, write reposition (lseek), delete, open, close ๋ฑ
- ํ์ผ ์์ฒด์ ๋ด์ฉ์ด ์๋๋ผ ํ์ผ์ ๊ด๋ฆฌํ๊ธฐ ์ํ ์ ๋ณด๋ค
- ํ์ผ ์ด๋ฆ, ์ ํ, ์ ์ฅ๋ ์์น, ํ์ผ ์ฌ์ด์ฆ
- ์ ๊ทผ ๊ถํ(์ฝ๊ธฐ/์ฐ๊ธฐ/์คํ), ์๊ฐ (์์ฑ/๋ณ๊ฒฝ/์ฌ์ฉ), ์์ ์ ๋ฑ
- ์ด์์ฒด์ ์์ ํ์ผ์ ๊ด๋ฆฌํ๋ ๋ถ๋ถ
- ํ์ผ ๋ฐ ํ์ผ์ ๋ฉํ๋ฐ์ดํฐ, ๋๋ ํ ๋ฆฌ ์ ๋ณด๋ฑ์ ๊ด๋ฆฌ
- ํ์ผ์ ์ ์ฅ ๋ฐฉ๋ฒ ๊ฒฐ์
- ํ์ผ ๋ณดํธ ๋ฑ
- ํ์ผ์ ๋ฉํ๋ฐ์ดํฐ ์ค ์ผ๋ถ๋ฅผ ๋ณด๊ดํ๊ณ ์๋ ์ผ์ข ์ ํน๋ณํ ํ์ผ
- ๊ทธ ๋๋ ํ ๋ฆฌ์ ์ํ ํ์ผ ์ด๋ฆ ๋ฐ ํ์ผ attribute๋ค
- operation
- search for a file, create a file, delete a file
- list a directory, rename a file, traverse the file system
- ํ๋์ (๋ฌผ๋ฆฌ์ ) ๋์คํฌ ์์ ์ฌ๋ฌ ํํฐ์ ์ ๋๋๊ฒ ์ผ๋ฐ์
- ์ฌ๋ฌ ๊ฐ์ ๋ฌผ๋ฆฌ์ ์ธ ๋์คํฌ๋ฅผ ํ๋์ ํํฐ์ ์ผ๋ก ๊ตฌ์ฑํ๊ธฐ๋ ํจ
- (๋ฌผ๋ฆฌ์ ) ๋์คํฌ๋ฅผ ํํฐ์ ์ผ๋ก ๊ตฌ์ฑํ ๋ค ๊ฐ๊ฐ์ ํํฐ์ ์ file system์ ๊น๊ฑฐ๋ swapping๋ฑ ๋ค๋ฅธ ์ฉ๋๋ก ์ฌ์ฉํ ์ ์์
- ๋์คํฌ๋ก๋ถํฐ ํ์ผ c์ ๋ฉํ๋ฐ์ดํฐ๋ฅผ ๋ฉ๋ชจ๋ฆฌ๋ก ๊ฐ์ง๊ณ ์ด
- ์ด๋ฅผ ์ํ์ฌ directory path๋ฅผ search
- ๋ฃจํธ ๋๋ ํ ๋ฆฌ "/"๋ฅผ openํ๊ณ ๊ทธ ์์์ ํ์ผ "a"์ ์์น ํ๋
- ํ์ผ "a"๋ฅผ openํ ํ readํ์ฌ ๊ทธ ์์์ ํ์ผ "b"์ ์์น ํ๋
- ํ์ผ "b"๋ฅผ openํ ํ readํ์ฌ ๊ทธ ์์์ ํ์ผ "c"์ ์์น ํ๋
- ํ์ผ "c"๋ฅผ openํ๋ค.
- Directory path์ search์ ๋๋ฌด ๋ง์ ์๊ฐ ์์
- Open์ read / write์ ๋ณ๋๋ก ๋๋ ์ด์ ์
- ํ๋ฒ openํ ํ์ผ์ read/write์ directory seach ๋ถํ์
- Open file table
- ํ์ฌ open๋ ํ์ผ๋ค์ ๋ฉํ๋ฐ์ดํฐ ๋ณด๊ด์ (in memory)
- ๋์คํฌ์ ๋ฉํ๋ฐ์ดํฐ๋ณด๋ค ๋ช ๊ฐ์ง ์ ๋ณด๊ฐ ์ถ๊ฐ
- openํ ํ๋ก์ธ์ค์ ์
- File offset : ํ์ผ ์ด๋ ์์น ์ ๊ทผ์ค์ธ์ง ํ์(๋ณ๋ ํ ์ด๋ธ ํ์)
- File descripter (file handle, file control block)
- Open file table์ ๋ํ ์์น ์ ๋ณด (ํ๋ก์ธ์ค ๋ณ)
- ๊ฐ ํ์ผ์ ๋ํด ๋๊ตฌ์๊ฒ ์ด๋ค ์ ํ์ ์ ๊ทผ(read/write/execution)์ ํ๋ฝํ ๊ฒ์ธ๊ฐ?
- Access control list : ํ์ผ๋ณ๋ก ๋๊ตฌ์ ์ด๋ค ์ ๊ทผ ๊ถํ์ด ์๋์ง ํ์
- Capability : ์ฌ์ฉ์๋ณ๋ก ์์ ์ด ์ ๊ทผ ๊ถํ์ ๊ฐ์ง ํ์ผ ๋ฐ ํด๋น ๊ถํ ํ์
- ์ ์ฒด user๋ฅผ owner, group, public์ ์ธ ๊ทธ๋ฃน์ผ๋ก ๊ตฌ๋ถ
- ๊ฐ ํ์ผ์ ๋ํด ์ธ ๊ทธ๋ฃน์ ์ ๊ทผ ๊ถํ(rwx)๋ฅผ 3๋นํธ์ฉ์ผ๋ก ํ์
- ์) Unix (owner | group | other)
- ํ์ผ๋ง๋ค password๋ฅผ ๋๋ ๋ฐฉ๋ฒ(๋๋ ํ ๋ฆฌ ํ์ผ์ ๋๋ ๋ฐฉ๋ฒ๋ ๊ฐ๋ฅ)
- ๋ชจ๋ ์ ๊ทผ ๊ถํ์ ๋ํด ํ๋์ password : all-or-nothing
- ์ ๊ทผ ๊ถํ๋ณ password : ์๊ธฐ ๋ฌธ์ , ๊ด๋ฆฌ ๋ฌธ์
- ์์ฐจ ์ ๊ทผ(sequential access)
- ์นด์ธํธ ํ ์ดํ๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ์์ฒ๋ผ ์ ๊ทผ
- ์ฝ๊ฑฐ๋ ์ฐ๋ฉด offset์ ์๋์ ์ผ๋ก ์ฆ๊ฐ
- ์ง์ ์ ๊ทผ(direct access, random access)
- LP ๋ ์ฝ๋ ํ๊ณผ ๊ฐ์ด ์ ๊ทผํ๋๋ก ํจ
- ํ์ผ์ ๊ตฌ์ฑํ๋ ๋ ์ฝ๋๋ฅผ ์์์ ์์๋ก ์ ๊ทผํ ์ ์์
- Contiguous Allocation
- Linked Allocation
- Indexed Allocation
- ๋จ์
- external fragmentation
- File grow๊ฐ ์ด๋ ค์
- file ์์ฑ์ ์ผ๋ง๋ ํฐ hole์ ๋ฐฐ๋นํ ๊ฒ์ธ๊ฐ ?
- grow ๊ฐ๋ฅ vs ๋ญ๋น (internal fragmentation)
- ์ฅ์
- Fast I/O
- ํ๋ฒ์ seek/rotation์ผ๋ก ๋ง์ ๋ฐ์ดํธ transfer
- Realtime file์ฉ์ผ๋ก, ๋๋ ์ด๋ฏธ run ์ค์ด๋ process์ swapping
- Direct access(=random access) ๊ฐ๋ฅ
- Fast I/O
-
์ฅ์
- External fragmentation ๋ฐ์ ์ ํจ
-
๋จ์
- No random access
- Reliability ๋ฌธ์
- ํ sector๊ฐ ๊ณ ์ฅ๋ pointer๊ฐ ์ ์ค๋๋ฉด ๋ง์ ๋ถ๋ถ์ ์์
- Pointer๋ฅผ ์ํ ๊ณต๊ฐ์ด block์ ์ผ๋ถ๊ฐ ๋์ด ๊ณต๊ฐ ํจ์จ์ฑ์ ๋จ์ด๋จ๋ฆผ
- 512 bytes/secore, 4bytes/pointer
-
๋ณํ
- File-allocation table(FAT) ํ์ผ ์์คํ
- ํฌ์ธํฐ๋ฅผ ๋ณ๋์ ์์น์ ๋ณด๊ดํ์ฌ reliability์ ๊ณต๊ฐํจ์จ์ฑ ๋ฌธ์ ํด๊ฒฐ
- File-allocation table(FAT) ํ์ผ ์์คํ
- ์ฅ์
- External fragmentatio์ด ๋ฐ์ํ์ง ์์
- Direct access ๊ฐ๋ฅ
- ๋จ์
- Small file์ ๊ฒฝ์ฐ ๊ณต๊ฐ ๋ญ๋น(์ค์ ๋ก ๋ง์ file๋ค์ด small)
- Too Large file์ ๊ฒฝ์ฐ ํ๋์ block์ผ๋ก index๋ฅผ ์ ์ฅํ๊ธฐ์ ๋ถ์กฑ
- ํด๊ฒฐ๋ฐฉ์
-
- linked scheme
-
- multi-level index
-
- ํด๊ฒฐ๋ฐฉ์
Partition
{
Boot block,
Super block,
[]Inode list,
Data block
}
Inode list
{
mode,
owners(2),
timestamps(3),
size block,
count,
direct blocks [data....],
single indirect,
double indirect,
triple indirect
}
- Boot block
- ๋ถํ ์ ํ์ํ ์ ๋ณด (bootstrap loader)
- Superblock
- ํ์ผ์์คํ ์ ๊ดํ ์ด์ฒด์ ์ธ ์ ๋ณด๋ฅผ ๋ด๊ณ ์๋ค.
- Inode
- ํ์ผ ์ด๋ฆ์ ์ ์ธํ ํ์ผ์ ๋ชจ๋ ๋ฉํ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅ
- Data block
- ํ์ผ์ ์ค์ ๋ด์ฉ์ ๋ณด๊ด
bit[i] = {
0 => block[i] free
1 => block[i] occupied
}
- Bit map์ ๋ถ๊ฐ์ ์ธ ๊ณต๊ฐ์ ํ์๋ก ํจ
- ์ฐ์์ ์ธ n๊ฐ์ free block์ ์ฐพ๋๋ฐ ํจ๊ณผ์
-
Linked list
- ๋ชจ๋ free block๋ค์ ๋งํฌ๋ก ์ฐ๊ฒฐ (free list)
- ์ฐ์์ ์ธ ๊ฐ์ฉ๊ณต๊ฐ์ ์ฐพ๋ ๊ฒ์ ์ฝ์ง ์๋ค.
- ๊ณต๊ฐ์ ๋ญ๋น๊ฐ ์๋ค.
-
Grouping
- linked list ๋ฐฉ๋ฒ์ ๋ณํ
- ์ฒซ๋ฒ์งธ free block์ด n๊ฐ์ pointer๋ฅผ ๊ฐ์ง
- n-1 pointer๋ free data block์ ๊ฐ๋ฆฌํด
- ๋ง์ง๋ง pointer๊ฐ ๊ฐ๋ฆฌํค๋ block์ ๋ ๋ค์ n pointer๋ฅผ ๊ฐ์ง
-
Counting
- ํ๋ก๊ทธ๋จ๋ค์ด ์ข ์ข ์ฌ๋ฌ ๊ฐ์ ์ฐ์์ ์ธ block์ ํ ๋นํ๊ณ ๋ฐ๋ฉํ๋ค๋ ์ฑ์ง์ ์ฐฉ์
- (first free block, # of contiguous free blocks)์ ์ ์ง
-
Linear list
- <file name, file์ metadata>์ list
- ๊ตฌํ์ด ๊ฐ๋จ
- ๋๋ ํ ๋ฆฌ ๋ด์ ํ์ผ์ด ์๋์ง ์ฐพ๊ธฐ ์ํด์๋ linear search ํ์ (time-consuming)
-
Hash Table
- linear list + hashing
- Hash table์ file name์ ์ด ํ์ผ์ linear list์ ์์น๋ก ๋ฐ๊พธ์ด์ค
- search time์ ์์ฐ
- Collision ๋ฐ์ ๊ฐ๋ฅ
-
Virtual File System(VFS)
- ์๋ก ๋ค๋ฅธ ๋ค์ํ file system์ ๋ํด ๋์ผํ ์์คํ ์ฝ ์ธํฐํ์ด์ค(API)๋ฅผ ํตํด ์ ๊ทผํ ์ ์๊ฒ ํด์ฃผ๋ OS์ layer
-
Network File System(NFS)
- ๋ถ์ฐ ์์คํ ์์๋ ๋คํธ์ํฌ๋ฅผ ํตํด ํ์ผ์ด ๊ณต์ ๋ ์ ์์
- NFS๋ ๋ถ์ฐ ํ๊ฒฝ์์์ ๋ํ์ ์ธ ํ์ผ ๊ณต์ ๋ฐฉ๋ฒ์
- Page Cache
- Virtual memory์ paging system์์ ์ฌ์ฉํ๋ page frame์ caching์ ๊ด์ ์์ ์ค๋ช ํ๋ ์ฉ์ด
- Memory-Mapped I/O๋ฅผ ์ฐ๋ ๊ฒฝ์ฐ file์ I/O์์๋ page cache ์ฌ์ฉ
- Memory-Mapped I/O
- File์ ์ผ๋ถ๋ฅผ virtual memory์ mapping์ํด
- ๋งคํ์ํจ ์์ญ์ ๋ํ ๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ ์ฐ์ฐ์ ํ์ผ์ ์ ์ถ๋ ฅ์ ์ํํ๊ฒ ํจ
- Buffer Cache
- ํ์ผ์์คํ ์ ํตํ I/O ์ฐ์ฐ์ ๋ฉ๋ชจ๋ฆฌ์ ํน์ ์์ญ์ธ buffer cache ์ฌ์ฉ
- File ์ฌ์ฉ์ locality ํ์ฉ
- ํ๋ฒ ์ฝ์ด์จ block์ ๋ํ ํ์ ์์ฒญ์ buffer cache์์ ์ฆ์ ์ ๋ฌ
- ๋ชจ๋ ํ๋ก์ธ์ค๊ฐ ๊ณต์ฉ์ผ๋ก ์ฌ์ฉ
- Replacement algorithm ํ์ (LRU, LFU ๋ฑ)
- Unified Buffer Cache
- ์ต๊ทผ์ OS์์๋ ๊ธฐ์กด์ buffer cache๊ฐ page cache์ ํตํฉ๋จ
- logical block
- ๋์คํฌ์ ์ธ๋ถ์์ ๋ณด๋ ๋์คํฌ์ ๋จ์ ์ ๋ณด ์ ์ฅ ๊ณต๊ฐ๋ค
- ์ฃผ์๋ฅผ ๊ฐ์ง 1์ฐจ์ ๋ฐฐ์ด์ฒ๋ผ ์ทจ๊ธ
- ์ ๋ณด๋ฅผ ์ ์กํ๋ ์ต์ ๋จ์
- Sector
- Logical block์ด ๋ฌผ๋ฆฌ์ ์ธ ๋์คํฌ์ ๋งคํ๋ ์์น
- Sector 0์ ์ต์ธ๊ณฝ ์ค๋ฆฐ๋์ ์ฒซ ํธ๋์ ์๋ ์ฒซ ๋ฒ์งธ ์นํฐ์ด๋ค.
- Access time์ ๊ตฌ์ฑ
- Seek time
- ํค๋๋ฅผ ํด๋น ์ค๋ฆฐ๋๋ก ์์ง์ด๋๋ฐ ๊ฑธ๋ฆฌ๋ ์๊ฐ
- Rotational latency
- ํค๋๊ฐ ์ํ๋ ์นํฐ์ ๋๋ฌํ๊ธฐ๊น์ง ๊ฑธ๋ฆฌ๋ ํ์ ์ง์ฐ์๊ฐ
- Transfer time
- ์ค์ ๋ฐ์ดํฐ์ ์ ์ก ์๊ฐ
- Seek time
- Disk bandwith
- ๋จ์ ์๊ฐ ๋น ์ ์ก๋ ๋ฐ์ดํธ์ ์
- Disk Scheduling
- seek time์ ์ต์ํํ๋ ๊ฒ์ด ๋ชฉํ
- Seek time ~ seek distance
-
physical formatting (Low-level formatting)
- ๋์คํฌ๋ฅผ ์ปจํธ๋กค๋ฌ๊ฐ ์ฝ๊ณ ์ธ ์ ์๋๋ก ์นํฐ๋ค๋ก ๋๋๋ ๊ณผ์
- ๊ฐ ์นํฐ๋ header + ์ค์ data(๋ณดํต 512 bytes) + trailer๋ก ๊ตฌ์ฑ
- header์ trailer๋ sector number, ECC (Error-Correcting Code) ๋ฑ์ ์ ๋ณด๊ฐ ์ ์ฅ๋๋ฉฐ controller๊ฐ ์ง์ ์ ๊ทผ ๋ฐ ์ด์
-
Partitioning
- ๋์คํฌ๋ฅผ ํ๋ ์ด์์ ์ค๋ฆฐ๋ ๊ทธ๋ฃน์ผ๋ก ๋๋๋ ๊ณผ์
- OS๋ ์ด๊ฒ์ ๋ ๋ฆฝ์ disk๋ก ์ทจ๊ธ(logical disk)
-
Logical formatting
- ํ์ผ ์์คํ ์ ๋ง๋๋ ๊ฒ
- FAT, inode, free space ๋ฑ์ ๊ตฌ์กฐ ํฌํจ
-
Booting
- ROM์ ์๋ "small bootstrap loader"์ ์คํ
- sector 0 (boot block)์ loadํ์ฌ ์คํ
- sector 0์ "full Bootstrap loader program"
- OS๋ฅผ ๋์คํฌ์์ loadํ์ฌ ์คํ
- ํ์ ๋ค์๊ณผ ๊ฐ์ ์ค๋ฆฐ๋ ์์น์ ์์ฒญ์ด ์กด์ฌํ๋ ๊ฒฝ์ฐ ๋์คํฌ ํค๋ 53๋ฒ์์ ์์ํ ๊ฐ ์๊ณ ๋ฆฌ์ฆ์ ์ํ ๊ฒฐ๊ณผ๋ ?
- 98, 183, 37, 122, 14, 124, 65, 67
- FCFS
- SSTF
- SCAN
- C-SCAN
- N-SCAN
- LOOK
- C-LOOK
- ์ด head์ ์ด๋ : 640 cylinders
- head starts at 53
- starvation ๋ฌธ์
- ์ด head์ ์ด๋ : 236 cylinders
- disk arm์ด ๋์คํฌ์ ํ์ชฝ ๋์์ ๋ค๋ฅธ์ชฝ ๋์ผ๋ก ์ด๋ํ๋ฉฐ ๊ฐ๋ ๊ธธ๋ชฉ์ ์๋ ๋ชจ๋ ์์ฒญ์ ์ฒ๋ฆฌํ๋ค.
- ๋ค๋ฅธ ํ์ชฝ ๋์ ๋๋ฌํ๋ฉด ์ญ๋ฐฉํฅ์ผ๋ก ์ด๋ํ๋ฉฐ ์ค๋ ๊ธธ๋ชฉ์ ์๋ ๋ชจ๋ ์์ฒญ์ ์ฒ๋ฆฌํ๋ฉฐ ๋ค์ ๋ฐ๋์ชฝ ๋์ผ๋ก ์ด๋ํ๋ค.
- ๋ฌธ์ ์ : ์ค๋ฆฐ๋ ์์น์ ๋ฐ๋ผ ๋๊ธฐ ์๊ฐ์ด ๋ค๋ฅด๋ค.
- ์ด head์ ์ด๋ : 208 cylinders
- ํค๋๊ฐ ํ์ชฝ ๋์์ ๋ค๋ฅธ์ชฝ ๋์ผ๋ก ์ด๋ํ๋ฉฐ ๊ฐ๋ ๊ธธ๋ชฉ์ ์๋ ๋ชจ๋ ์์ฒญ์ ์ฒ๋ฆฌ
- ๋ค๋ฅธ์ชฝ ๋์ ๋๋ฌํ์ผ๋ฉด ์์ฒญ์ ์ฒ๋ฆฌํ์ง ์๊ณ ๊ณง๋ฐ๋ก ์ถ๋ฐ์ ์ผ๋ก ๋ค์ ์ด๋
- SCAN๋ณด๋ค ๊ท ์ผํ ๋๊ธฐ ์๊ฐ์ ์ ๊ณตํ๋ค.
- N-SCAN
- SCAN์ ๋ณํ ์๊ณ ๋ฆฌ์ฆ
- ์ผ๋จ arm์ด ํ ๋ฐฉํฅ์ผ๋ก ์์ง์ด๊ธฐ ์์ํ๋ฉด ๊ทธ ์์ ์ดํ์ ๋์ฐฉํ job์ ๋๋์์ฌ ๋ service
- LOOK and C-LOCK
- SCAN์ด๋ C-SCAN์ ํค๋๊ฐ ๋์คํฌ ๋์์ ๋์ผ๋ก ์ด๋
- LOOK๊ณผ C-LOOK์ ํค๋๊ฐ ์งํ์ค์ด๋ค๊ฐ ๊ทธ ๋ฐฉํฅ์ ๋์ด์ ๊ธฐ๋ค๋ฆฌ๋ ์์ฒญ์ด ์์ผ๋ฉด ํค๋์ ์ด๋๋ฐฉํฅ์ ์ฆ์ ๋ฐ๋๋ก ์ด๋
- SCAN, C-SCAN ๋ฐ ๊ทธ ์์ฉ ์๊ณ ๋ฆฌ์ฆ์ LOOK, C-LOOK ๋ฑ์ด ์ผ๋ฐ์ ์ผ๋ก ๋์คํฌ ์ ์ถ๋ ฅ์ด ๋ง์ ์์คํ ์์ ํจ์จ์ ์ธ ๊ฒ์ผ๋ก ์๋ ค์ ธ ์์
- File์ ํ ๋น ๋ฐฉ๋ฒ์ ๋ฐ๋ผ ๋์คํฌ ์์ฒญ์ด ์ํฅ์ ๋ฐ์
- ๋์คํฌ ์ค์ผ์ค๋ง ์๊ณ ๋ฆฌ์ฆ์ ํ์ํ ๊ฒฝ์ฐ ๋ค๋ฅธ ์๊ณ ๋ฆฌ์ฆ์ผ๋ก ์ฝ๊ฒ ๊ต์ฒดํ ์ ์๋๋ก OS์ ๋ณ๋์ ๋ชจ๋๋ก ์์ฑ๋๋ ๊ฒ์ด ๋ฐ๋์งํ๋ค.
- Disk๋ฅผ ์ฌ์ฉํ๋ ๋ ๊ฐ์ง ์ด์
- memory์ volatileํ ํน์ฑ > file system
- ํ๋ก๊ทธ๋จ ์คํ์ ์ํ memory๊ณต๊ฐ ๋ถ์กฑ > swap space(swap area)
- Swap-space
- Virtual memory system์์๋ ๋์คํฌ๋ฅผ memory์ ์ฐ์ฅ ๊ณต๊ฐ์ผ๋ก ์ฌ์ฉ
- ํ์ผ์์คํ
๋ด๋ถ์ ๋ ์๋ ์์ผ๋ ๋ณ๋ partition ์ฌ์ฉ์ด ์ผ๋ฐ์
- ๊ณต๊ฐํจ์จ์ฑ๋ณด๋ค๋ ์๋ ํจ์จ์ฑ์ด ์ฐ์
- ์ผ๋ฐ ํ์ผ๋ณด๋ค ํจ์ฌ ์งง์ ์๊ฐ๋ง ์กด์ฌํ๊ณ ์์ฃผ ์ฐธ์กฐ๋จ
- ๋ฐ๋ผ์, block์ ํฌ๊ธฐ ๋ฐ ์ ์ฅ ๋ฐฉ์์ด ์ผ๋ฐ ํ์ผ์์คํ ๊ณผ ๋ค๋ฆ
- RAID(Redundant Array of Independent Disks)
- ์ฌ๋ฌ ๊ฐ์ ๋์คํฌ๋ฅผ ๋ฌถ์ด์ ์ฌ์ฉ
- RAID์ ์ฌ์ฉ ๋ชฉ์
- ๋์คํฌ ์ฒ๋ฆฌ ์๋ ํฅ์
- ์ฌ๋ฌ ๋์คํฌ์ block์ ๋ด์ฉ์ ๋ถ์ฐ ์ ์ฅ
- ๋ณ๋ ฌ์ ์ผ๋ก ์ฝ์ด์ด (interleaving, striping)
- ์ ๋ขฐ์ฑ(reliability) ํฅ์
- ๋์ผ ์ ๋ณด๋ฅผ ์ฌ๋ฌ ๋์คํฌ์ ์ค๋ณต ์ ์ฅ
- ํ๋์ ๋์คํฌ๊ฐ ๊ณ ์ฅ(failure)์ ๋ค๋ฅธ ๋์คํฌ์์ ์ฝ์ด์ด(Mirroring, shadowing)
- ๋จ์ํ ์ค๋ณต ์ ์ฅ์ด ์๋๋ผ ์ผ๋ถ ๋์คํฌ์ parity๋ฅผ ์ ์ฅํ์ฌ ๊ณต๊ฐ์ ํจ์จ์ฑ์ ๋์ผ ์ ์๋ค.
- ๋์คํฌ ์ฒ๋ฆฌ ์๋ ํฅ์