๐ CPU ์ค์ผ์ค๋ฌ(Scheduler)
fork: ํ๋ก์ธ์ค๋ฅผ ๋ฎ์ด์์
Execlp: ํ๋์ ํ๋ก์ธ์ค๋ฅผ ๋ค๋ฅธ ํ๋ก์ธ์ค๋ก ๋ฎ์ด ์์ฐ๋ ์ญํ ์ ํจ
Wait: ํ๋ก์ธ์ค A๊ฐ wait() ์์คํ ์ฝ์ ํธ์ถํ๋ฉด ์ปค๋์ child๊ฐ ์ข ๋ฃ๋ ๋๊น์ง ํ๋ก์ธ์ค A๋ฅผ sleep ์ํจ๋ค. (block ์ํ), child process๊ฐ ์ข ๋ฃ๋๋ฉด ์ปค๋์ ํ๋ก์ธ์ค A๋ฅผ ๊นจ์ด๋ค. (Ready ์ํ)
exit: ํ๋ก์ธ์ค๋ฅผ ์ข ๋ฃ์ํค๋ ์์คํ ์ฝ
- ์๋ฐ์ ์ข
๋ฃ
- ๋ง์ง๋ง statement ์ํ ํ exit()๋ฅผ ์ํ
- ํ๋ก๊ทธ๋จ์ ๋ช ์์ ์ผ๋ก ๋ฃ์ด์ฃผ์ง ์์๋ ํจ์๊ฐ return๋๋ ํ๋ก์ธ์ค์ ์ปดํ์ผ๋ฌ๊ฐ ๋ฃ์ด์ค
- ๋น์๋ฐ์ ์ข
๋ฃ
- ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ์์ ํ๋ก์ธ์ค๋ฅผ ๊ฐ์ ๋ก ์ข
๋ฃ์ํด
- ์์ ํ๋ก์ธ์ค๊ฐ ํ๊ณ์น๋ฅผ ๋์ด์๋ ์์์ ์์ฒญํ๊ฑฐ๋
- ์์ ํ๋ก์ธ์ค์ ํ ๋น๋ ํ ์คํฌ๊ฐ ๋์ด์ ํ์๊ฐ ์์ ๋
- ํค๋ณด๋๋ก kill, break ๋ฑ์ ์น ๊ฒฝ์ฐ
- ๋ถ๋ชจ๊ฐ ์ข
๋ฃํ๋ ๊ฒฝ์ฐ
- ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ์ข ๋ฃํ๊ธฐ ์ ์ ์์ ํ๋ก์ธ์ค๊ฐ ๋จผ์ ์ข ๋ฃ๋จ.
- ๋ถ๋ชจ ํ๋ก์ธ์ค๊ฐ ์์ ํ๋ก์ธ์ค๋ฅผ ๊ฐ์ ๋ก ์ข
๋ฃ์ํด
ํ๋ก์ธ์ค๊ฐ ํ๋ ฅ
- ๋ ๋ฆฝ์ ํ๋ก์ธ์ค: ํ๋ก์ธ์ค๋ ๊ฐ์์ ์ฃผ์ ๊ณต๊ฐ์ ๊ฐ๊ณ ์ํ๋๋ฏ๋ก ์์น์ ์ผ๋ก ํ๋์ ํ๋ก์ธ์ค๋ ๋ค๋ฅธ ํ๋ก์ธ์ค์ ์ํฅ์ ๋ฏธ์น์ง ๋ชปํจ.
- ํ๋ ฅ์ ํ๋ก์ธ์ค: ํ๋ก์ธ์ค์ ํ๋ ฅ ๋ฉ์ปค๋์ฆ์ ํตํด ํ๋์ ํ๋ก์ธ์ค๊ฐ ๋ค๋ฅธ ํ๋์ ํ๋ก์ธ์ค์ ์ํ์ ์ํฅ์ ๋ฏธ์น ์ ์์.
- ํ๋ก์ธ์ค๊ฐ ํ๋ ฅ ๋ฉ์ปค๋์ฆ(IPC: InterProcess Communication)
- ๋ฉ์ธ์ง๋ฅผ ์ ๋ฌํ๋ ๋ฐฉ๋ฒ
- ์ปค๋์ ํตํด ๋ฉ์ธ์ง๋ฅผ ์ ๋ฌ(Message Passing)
- Message system: ํ๋ก์ธ์ค ์ฌ์ด์ ๊ณต์ ๋ณ์(shared variable)๋ฅผ ์ผ์ฒด ์ฌ์ฉํ์ง ์๊ณ ํต์ ํ๋ ์์คํ
- Direct Communication: ํต์ ํ๋ ค๋ ํ๋ก์ธ์ค๋ฅผ ๋ช ์์ ์ผ๋ก ํ์ (ํ๋ ฅํ ํ๋ก์ธ์ค๊ฐ ๋ช ํํจ)
- Indirect Communication: mailbox (๋๋ port)๋ฅผ ํตํด ๋ฉ์ธ์ง๋ฅผ ๊ฐ์ ์ ์ผ๋ก ์ ๋ฌ (์ผ๋จ mailbox์ ๋ฃ์ด๋๊ณ ๋ค๋ฅธ ํ๋ก์ธ์ค๊ฐ ๊ฐ์ ธ๊ฐ์ ํ๋ ฅ ํจ)
- ์ฃผ์ ๊ณต๊ฐ์ ๊ณต์ ํ๋ ๋ฐฉ๋ฒ
- Shared memory: ์๋ก ๋ค๋ฅธ ํ๋ก์ธ์ค ๊ฐ์ ์๋ก ๊ณต์ ํ๋ shared memory ๋ฉ์ปค๋์ฆ์ด ์์ / ์ฃผ์ํ ์ ( ํ๋ก์ธ์ค ๊ฐ์ ์ ๋ขฐ๋ฅผ ํ ์ ์์ด์ผ ํจ. )
- thread์ ๊ฒฝ์ฐ ์ฌ์ค์ ํ๋์ ํ๋ก์ธ์ค์ด๋ฏ๋ก ์๋ก ๊ด์ฌํ๋ค๊ณ ๋ณด๊ธฐ๋ ์ด๋ ต์ง๋ง, ๋์ผํ process๋ฅผ ๊ณต์ ํ๋ thread๊ฐ์๋ ์ฃผ์ ๊ณต๊ฐ์ ๊ณต์ ํ๋ฏ๋ก ํ๋ ฅ์ด ๊ฐ๋ฅํ๋ค.
- ๋ฉ์ธ์ง๋ฅผ ์ ๋ฌํ๋ ๋ฐฉ๋ฒ
ํ๋ก์ธ์ค์ ํน์ฑ ๋ถ๋ฅ
- ํ๋ก์ธ์ค๋ ๊ทธ ํน์ฑ์ ๋ฐ๋ผ 2๊ฐ์ง๋ก ๋๋จ
- I/O bound process: CPU๋ฅผ ์ก๊ณ ๊ณ์ฐํ๋ ์๊ฐ๋ณด๋ค I/O์ ๋ง์ ์๊ฐ์ด ํ์ํ job(many short cpu bursts)
- CPU-bound process: ๊ณ์ฐ ์์ฃผ์ job (few very long CPU bursts)
CPU process & Dispatcher (Software)
- CPU Scheduler
- Ready ์ํ์ ํ๋ก์ธ์ค ์ค ์ด๋ฒ์ CPU๋ฅผ ์ค ํ๋ก์ธ์ค๋ฅผ ๊ณ ๋ฅธ๋ค.
- Dispatcher
- CPU์ ์ ์ด๊ถ์ CPU Scheduler์ ์ํด ์ ํ๋ ํ๋ก์ธ์ค์๊ฒ ๋๊ธด๋ค.
- ์ด ๊ณผ์ ์ context switch(๋ฌธ๋งฅ ๊ตํ)์ด๋ผ๊ณ ํ๋ค.
- CPU ์ค์ผ์ค๋ง์ด ํ์ํ ๊ฒฝ์ฐ๋ ๋ค์๊ณผ ๊ฐ์ ์ํ ๋ณํ๊ฐ ์๋ ๊ฒฝ์ฐ์ด๋ค.
-
- Running โ Blocked (์: I/O ์์ฒญ์ ํ๋ ์์คํ ์ฝ)
-
- Running โ Ready (์: ํ ๋น์๊ฐ๋ง๋ฃ๋ก timer interrupt)
-
- Blocked โ Ready ( I/O ์๋ฃ ํ ์ธํฐ๋ฝํธ)
-
- Terminate
- (1, 4)์ ๊ณผ์ ์ nonpreemptive(=๊ฐ์ ๋ก ๋นผ์์ง ์๊ณ ์์ง ๋ฐ๋ฉ)
- All other scheduling is preemptive(=๊ฐ์ ๋ก ๋นผ์์)
-
Scheduling criteria(Performance Index=์ฑ๋ฅ ์ฒ๋)
- 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
- wating time (๋๊ธฐ ์๊ฐ)
- amount of time a process has been 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)