Post

PCB, Contect Switching

✅ Process Management

manage multiple process by scheduling

  • in order for Process Management, CPU needs to know which process is who ➡️ Process Meatadata
  • Process Metadata
    • processID
    • process state
    • process priority
    • CPU registers
    • Owner
    • CPU usage
    • Memory usage
  • when process is created, Process Metadata is saved on PCB

✅ PCB

Process Control Block
save process matadata
one PCB has information of one process

Screenshot 2024-07-25 at 12 35 29

1. Program run
2. Process created
3. Process Address Space
    - code
    - data
    - stack
4. metadata of this process saved on PCB

Why need PCB?

in CPU, processes are run in order
process context, state is considered
when interrupt occurs, process wait/ other process run
> > save process that is waiting to be run on PCB

How is PCB managed?

linked list
PCB List Head + connect new PCB
connected with address
easy to insert, delete

✅ Context Switching

when running process is changed, change CPU register information save process info that was running on PCB, and save new process info from PCB and update CPU register

When does Context Switching occur?

when there is interrupt
consumed all CPU usage time
process needs to wait for input/output
basically, when CPU has to change the process that is running

✅ Context Switching Overhead

This post is licensed under CC BY 4.0 by the author.