Process Control Blocks
PCB (Process Control Block)
The PCB is the basic data structure the OS uses to control and manage processes. It represents a process's existence in the system and lets the system identify that process.
A PCB contains information such as the process identifier (PID), program counter, state, CPU-scheduling information, memory-management information, and I/O status.
Linux's task_struct process structure can be illustrated with the following fields; actual fields, types, and header locations vary by kernel version:
pid_t pid;
long state;
unsigned int time_slice;
struct task_struct *parent;
struct list_head children;
struct files_struct *files;
struct mm_struct *mm;When the CPU switches to another process, the system must save the current process's context and load the context of the process to execute. Process context is stored through the PCB and related kernel structures.
Save and restore two register banks
Unlock the complete interactive lab, deeper explanations, and curated reference answers.
Trace two suspended instruction streams
A starts at PC=100, ACC=0; B starts at PC=200, ACC=10. Each instruction increments both values by one.
- Execute A twice, switch to B, execute B once, and switch back. Record live and saved registers after each event.
- Explain why a saved A record need not change while A is executing.
- Name two switch costs outside the register values.