ํ๋ก์ธ์ค
๐น ํ๋ก์ธ์ค
- ์ฝ๋์ ์ผ๋ถ. ์คํ ์ค์ธ ํ๋ก๊ทธ๋จ
- ์๊ธฐ ๋ ๋ฆฝ์ ์ธ resource ๊ฐ์ง.
- single address space โก๏ธ protection
- ๋ค๋ฅธ ํ๋ก์ธ์ค์ ๊ณต์ X
๐น ํน์ง
- ํ๋ก์ธ์ค ๊ฐ๊ฐ ๊ณ ์ ์ ์คํ ๋ฉ๋ชจ๋ฆฌ ๋ณด์
- ๊ณ ์ ์ ๋ฉ๋ชจ๋ฆฌ ํ์ด์ง ๋ณด์
- ๊ณ ์ ์ file descriptor table ๋ณด์
- PID (Process ID)
๐น ํ๋ก์ธ์ค์ Context
- CPU ์ํ ์ํ๋ฅผ ๋ํ๋ด๋ ํ๋์จ์ด ๋ฌธ๋งฅ
- Program Counter
- register
- ํ๋ก์ธ์ค ์ฃผ์ ๊ณต๊ฐ
- code
- data
- stack
- ํ๋ก์ธ์ค ๊ด๋ จ ์ปค๋ ์๋ฃ๊ตฌ์กฐ
- PCB
- Kernel Stack
๐น ํ๋ก์ธ์ค ์์ฑ
- ์์์ ๋ถ๋ชจ์ ๊ณต๊ฐ์ ๋ณต์ฌํด ๊ทธ ๊ณต๊ฐ์ ์๋ก์ด ํ๋ก๊ทธ๋จ์ ์ฌ๋ฆผ
- ํธ๋ฆฌ(๊ณ์ธต ๊ตฌ์กฐ) ํ์ฑ
fork()
- ์์คํ ์ฝ์ ํตํด ์์ ๊ณผ ๋์ผํ ํ๋ก์ธ์ค ์์ฑ ๐ child process
- parent process โก๏ธ return value = PID of the child process (์์)
- child process โก๏ธ return value = '0'
- ์คํจ โก๏ธ return value = '-1'
exec()
- ์์คํ ์ฝ์ ํตํด ์๋ก์ด ํ๋ก๊ทธ๋จ์ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฆผ
- fork() ๋ค์์ ๋ฐ์
exit()
- ์์์ด ๋ถ๋ชจ์๊ฒ output data๋ฅผ ๋ณด๋ (via wait)
wait()
- ํ๋ก์ธ์ค A๊ฐ wait() ์์คํ ์ฝ์ ํธ์ถํ๋ฉด
- ๐ ์ปค๋์ child๊ฐ ์ข ๋ฃ๋ ๋๊น์ง ํ๋ก์ธ์ค A๋ฅผ sleep์ํด โ block ์ํ
- child process๊ฐ ์ข ๋ฃ๋๋ฉด ์ปค๋์ ํ๋ก์ธ์ค A๋ฅผ ๊นจ์ โ ready ์ํ
abort
- kill, break
- ๋น์๋ฐ์ ์ข ๋ฃ : ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ์์์ ์ํ์ ์ข ๋ฃ์ํด
- ์์์ด ํ ๋น ์์์ ํ๊ณ์น๋ฅผ ๋์ด์ค ๋ ์ฌ์ฉ
- ์์์๊ฒ ํ ๋น๋ ํ์คํฌ๊ฐ ๋ ์ด์ ํ์ํ์ง ์์ ๋ ์ฌ์ฉ
๐น ํ๋ก์ธ์ค ๊ด๋ฆฌ
- Zombie process
- ์ข ๋ฃ๋์์ง๋ง ์์ ํ ์๋ฉธ๋์ง ์์ ํ๋ก์ธ์ค
- ๋ถ๋ชจ ํ๋ก์ธ์ค์์ ์์ ํ๋ก์ธ์ค์ ์ข ๋ฃ ์ํ ์ฒ๋ฆฌ X ๐ ์ ์์ ์ด๋ผ๋ฉด ์์ ํ๋ก์ธ์ค๊ฐ SIGCHLD์ ๋ถ๋ชจ ํ๋ก์ธ์ค์๊ฒ ์ ๋ฌ
- ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฐจ์งํ๊ณ ์์ง๋ง ์คํ X โก๏ธ ์์คํ ์์ ๋ญ๋น
- Orphan process
- ์์ ํ๋ก์ธ์ค๋ณด๋ค ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ๋จผ์ ์ข ๋ฃ
- ๋ค๋ฅธ ๋ถ๋ชจ ๋ฐ์ผ๋ก ๋ณด๋ด์ผํจ ๐ ์์ ํ๋ก์ธ์ค๋ process 1(init=๋ชจ๋ ํ๋ก์ธ์ค์ ์กฐ์)์๊ฒ ๋ณด๋ด์ง.
๐น wait() ์์คํ ์ฝ
- ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ์์ ํ๋ก์ธ์ค์ ์ข ๋ฃ ์ํ ๋๊ธฐํ๊ณ ํด๋น ์ํ ๊ฐ์ ธ์ค๋ ๊ธฐ๋ฅ ์ํ
- ์์ ํ๋ก์ธ์ค์ ์์ ์ด ์๋ฃ๋ ๋๊น์ง ๋๊ธฐ
๐น ํ๋ก์ธ์ค ์ํ
- New : ํ๋ก์ธ์ค ์์ฑ → process management admitted
- Ready : ์ฝ๋ ์คํ ๊ฐ๋ฅ ์ํ ๐ CPU ์ฌ์ฉ X. ์ค์ผ์ค๋ฌ์ ์ํด dispatch → Running
- Running : ์ฝ๋ ์คํ ์ค ๐ CPU ์ฌ์ฉ O. interrupt์ ์ํด ์์ ์ค์งํ๊ณ Ready state
- Waiting : ์ธ๋ถ i/o device ์ ๊ทผ ๋๋ event(๋์คํฌ์์ ํ์ผ ์ฝ์ด์ค๊ธฐ ๋ฑ)
- Terminated : ํ๋ก์ธ์ค ์ข ๋ฃ
๐น PCB(Process Control Block)
- ํ๋ก์ธ์ค์ ๋ํ ์ ๋ณด ํฌํจ
- Process ID
- Parent PID
- Next Process Block → Linked-List
- Process State
- List of thread control blocks(TCBs)
- CPU info ๐ CPU register contents, Program counter
- Memory-mangement info
๐น Context-Switching
- context-switching : ์ปค๋์์ ๊ธฐ๋ฅ ์ ๊ณต
- ์ฌ๋ฌ ํ๋ก์ธ์ค๋ค์ด CPU ๊ณต์ ๐ PCB์ ์ ์ฅํ๊ฑฐ๋ ์ฝ์ด์์ ๋ค๋ฅธ ํ๋ก์ธ์ค๋ก ๋๊ฒจ์ค
- Process 1 running, Process 2 ready
- interrupt
- process 1์ CPU์ register ์ ๋ณด PCB1์ ์ ์ฅ
- ์ค์ผ์ค๋ฌ๊ฐ process 2 ์ ํ & PCB2๋ฅผ CPU์ ๋ณต์ → Running
- interrupt
- process 2์ CPU register ์ ๋ณด๋ฅผ PCB2์ ์ ์ฅ
- process 1๋ PCB1๋ฅผ CPU์ ๋ณต์
๐น ํ๋ก์ธ์ค ๊ฐ ํ๋ ฅ (IPC: Interprocess Communication)
- ๋ฉ์์ง ์ ๋ฌํ๋ ๋ฐฉ๋ฒ (Message Passing) : ์ปค๋์ ํตํด ๋ฉ์์ง ์ ๋ฌ
- ์ฃผ์ ๊ณต๊ฐ ๊ณต์ ํ๋ ๋ฐฉ๋ฒ
- Shared Memory : ์๋ก ๋ค๋ฅธ ํ๋ก์ธ์ค ๊ฐ์๋ ์ผ๋ถ ์ฃผ์ ๊ณต๊ฐ ๊ณต์
- Thread : ๋์ผํ ํ๋ก์ธ์ค๋ฅผ ๊ตฌ์ฑํ๋ thread ๊ฐ์ ์ฃผ์ ๊ณต๊ฐ ๊ณต์
'CS > โ๏ธ ์ด์์ฒด์ ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[โ๏ธ OS] ํ๋ก์ธ์ค ๊ฐ ํต์ (IPC: Inter-Process Communication) (0) | 2024.03.09 |
---|---|
[โ๏ธ OS] ํ๋ก์ธ์ค ๋๊ธฐํ (0) | 2024.03.09 |
[โ๏ธ OS] CPU ์ค์ผ์ค๋ง (1) | 2024.03.03 |
[โ๏ธ OS] Thread (0) | 2024.02.29 |