Process Control Block(PCB)
PCB는 각 process에 대한 모든 정보를 포함하는 memory 구조체이다.
process가 생성되게 되면 PCB가 main memory 안에 만들어지게 된다. 이 process가 종료되면 PCB가 free되게 만든다.
예를 들어 A process와 B process가 있다고 하자.
CPU의 할당이
A -> B로 switch 된다면 A의 상태를 저장해야 할 것이다.
(return address, 현재 program counter의 address를 저장해야 다시 process A로 돌아올 때 어디로 돌아올 것인지(어디서 시작할 것인지)를 알 수 있다.)
A의 return address를 가지고 있는 PCB의 내용들, process의 state, CPU register에 있는 내용들, scheduling에 대한 내용들(예를 들면 priority)
그래서 PCB 구조는 다음과 같다.

- process state: running, waiting, etc
- program counter: location of instruction to next execution
- CPU registers: contents of all process - centric registers
- CPU scheduling information: priorities, scheduling queue pointers
- memory - management information: memory allocated to the process
- Accounting information: CPU used, clock time, time limits
- I/O status information: I/O devices allocated to process, list of open files
task_struct{
pid t_pid; /* process identifier 각각의 process는 unique한 number가 있다 */
long state; /* state of the process */
unsigned int time_slice /* scheduling information, time quantum을 의미한다. */
struct task_struct *parent; /* this process's parent */
struct list_head *children; /* this process's children */
struct files_struct *files; /* list of open files 어떤 파일들을 open했는지 */
struct mm_struct *mm; /* address space of this process 메모리 영역에 대한 정보들 */
}
다음의 context switch 과정에서 PCB가 사용된다.
728x90
반응형
'운영체제' 카테고리의 다른 글
| 쓰레드(Threads)와 multi process 차이, java에서 thread 그룹 (0) | 2022.07.15 |
|---|---|
| CPU Switch From Process to Process (0) | 2022.07.15 |
| Process(프로세스) (0) | 2022.07.15 |
| 컴파일(Compile) (0) | 2022.07.14 |