1. Introduction to Process
Definition of Process
- Process: A process is a program in execution. It's more than just the code; it includes the program counter, stack, heap and data section. It is an active entity, unlike a program, which is a passive collection of instructions.
- Program vs. Process: A program becomes a process when it is loaded into memory and executed by the CPU. Multiple processes can originate from the same program, each operating independently.
Process States
- New: The process is being created. It hasn’t started executing yet.
- Running: The process's instructions are currently being executed by the CPU.
- Waiting: The process cannot proceed until some external event occurs, such as I/O completion.
- Ready: The process is in memory and ready to run when the CPU becomes available.
- Terminated: The process has finished execution and is being removed from memory.
2. Process Control Block (PCB)
Components of a PCB
- Process State: This indicates the current state of the process (New, Ready, Running, Waiting, Terminated).
- Process Number (PID): A unique identifier for each process.
- Program Counter: Points to the next instruction that the CPU will execute.
- CPU Registers: Store intermediate data and results during execution. They must be saved and restored during context switching.
- Memory Management Information: This includes base and limit registers, page tables, or segment tables depending on the memory management scheme used.