- S30~ ํ๋ฐ๋ถ๋ ๊ตฌํ ์ค๋ช
์๋ตํ์ฌ.
context ์ดํด ์ ๋ฆฌํ๊ณ IPCํํธ๋ ์ข
๋ฅ, ๋ช
์นญ - ์ปจ์
๋งค์น ์ ๋๋ง ํ๋๋ก ~
Process Concept
job (vs process)
- job; ์ปดํจํฐ์ ์ค์น๋ program + data (์คํ ์ฌ๋ถ ๊ด๊ณ x)
process context(5)
- program code -> text
- global data -> data
- temporary data -> stack
- local var, func param, ret adr ..
- dynamically allocated Mem area -> heap
- values of the proc regs
resource(vs process)
- passive entity (cf. process: active)
Process States & transition
- Determined by proc - rsc interaction
created state
K ์ proc ๋ฑ๋ก, PCB ํ ๋น๋ฐ์ ์ํ
- K : mem ๊ณต๊ฐ ํ์ธ -> O: ready / X: suspended state
Q. fork()?
- UNIX ๋ฐ ์ ๋์ค ๊ธฐ๋ฐ ์์คํ
์ฃผ์ ํ๋ก์ธ์ค ์์ฑ ๋ฉ์ปค๋์ฆ
- ์คํ ์ค์ธ ํ๋ก์ธ์ค๊ฐ ์์ ์ ๋ณต์ฌ๋ณธ์ ์์ฑํ๋ฉฐ,
๊ธฐ์กด: parent proc, ์์ฑ: child proc
- ์์ ํ๋ก์ธ์ค๋ ๋ถ๋ชจ ํ๋ก์ธ์ค๋ก๋ถํฐ ์ฝ๋, ์ด๊ธฐ ๋ฐ์ดํฐ ๋ฐ ์คํ, ํ, ํ๊ฒฝ ๋ณ์, ์ด๋ฆฐ ํ์ผ ๋์คํฌ๋ฆฝํฐ ๋ฑ์ ์์๋ฐ์ง๋ง
- ์์ ํ๋ก์ธ์ค๋ ๋
๋ฆฝ๋ ์คํ ์ค๋ ๋ ๊ฐ๊ณ ๋ณ๋๋ก ๋์ํ๋ฉฐ ์๋ก์ ๋ฉ๋ชจ๋ฆฌ์ ์ง์ ์ ๊ทผ ๋ถ๊ฐ
+์ฐธ๊ณ : fork() in c
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main() {
pid_t pid;
pid = fork();
if (pid < 0) {
perror("fork failed");
return 1;
}
if (pid == 0) {
printf("child process with PID: %d\n", getpid());
} else {
printf("the parent process with PID: %d, and my child's PID is: %d\n", getpid(), pid);
}
return 0;
}
Q. ๊ฐ์๊ธฐ ๋๋ ์๋ฌธ sys call์ system์ def??
๊ทธ๋ฅ OS..?
ready state
Mem O -> ๋ค๋ฅธ rsc ๋ค ์์ / CPU๋ง X
- if processor allocation ๊ฐ๋ฅ -> dispatch(=schedule)
if processor allocation ๊ฐ๋ฅ X -> ๊ทธ๋ฅ waiting
dispatch
CPU ํ ๋น
ready -> running state
running state
Mem O CPU O : ๋ค ์๋ค!
preemption
K์ด proc์ CPU ๋บ์
running -> ready state
- timerunout( expiration of time quantum )
- higher priority proc
block(sleep)
I/O syscall๋ก proc์ด CPU ๋ฐ๋ฉ, I/O ํ ๋น ๋ฐ์
running -> asleep state
- processor, mem์ธ ๋ค๋ฅธ rsc request
blocked(asleep) state
Mem O CPU X(๋ฐ๋ฉ) I/O O
wakeup
I/O ๋๋
blocked -> ready
suspended state
Mem X
- suspended ready & suspended asleep
swap out = suspend
losing mem
ready -> suspended ready
asleep -> suspended asleep
swap in = resume
getting mem
suspended ready -> ready
suspended asleep -> asleep -
terminated/zombie state
- PCB์ ์ผ๋ถ ์ ๋ณด ์ ์ธ ๋ชจ๋ rsc ๋ฐ๋ฉ
- ์ดํ ์ ๋ถ ๋ฐ๋ฉ
Process States in Unix(์ฐจ์ด์ )
-
1,2 : K, user์ running state๋ฅผ ๊ตฌ๋ณํจ
-
3,7 : ์ผ๋ฐ ready, preempted๋ฅผ ๊ตฌ๋ณํจ
-
๊ท์ฐจ๋ ์ํ ์ ์ ํด๋ณด๊ธฐ
Process States in Linux(์ฐจ์ด์ )
- ready ๋ task-running ์ด๋ผ ํด
- virtual Mem ์ด ์์ด์ suspended ์ํ๊ฐ ์์ ๊ตณ์ด ~?
Scheduling (๊ฐ๋จ)
Scheduler Queues
ready queue
asleep queue
- I/O reason๋ณ๋ก, ์ฌ๋ฌ๊ฐ
scheduler ์ข
๋ฅ(3๊ฐ์ง, term ๊ธฐ์ค)
- long-term - sys
- medium-term - mem, swapping
- short-term - cpu
Interrupt
interrupt handling process
- interrupt from external source
- pause process execution
- Interrupt handling
- check interrupt source, reason
- decision for interrupt service
์ง๊ธ ํ๋ ์ผ vs interrupt ์ฐ์ ์์ ๋น๊ต
- invoke ISR(interrupt service routine)
Context Switching
context (what)
ctx saving, restoring,switching
IPC(๋ญ ์ค์ธ๊ฑฐ๊ฒ)
IPC ํ์ -> process cooperation ํ์ ์ด์ ?
Scheme (2๊ฐ์ง)
Message passing
RPC (+ RMI, LRPC)
shared memory
DSM