Introduction to Processes in Operating Systems
What is a Process?
- A process is a program in execution, an active entity with a program counter, stack, heap, and other
resources.
- A program is a passive set of instructions stored on disk; it becomes a process when loaded into memory
and executed.
Example: Double-clicking a .exe file turns it from a program into a process. Opening it multiple times creates
multiple processes.
Evolution of Process Management
Early Systems:
- Supported only one program at a time (no multitasking).
- No process-level abstraction or simultaneous execution.
Modern Systems:
- Allow multiple programs to run at once via multiprocessing or multitasking.
- Handle system and user processes simultaneously.
- Even on single-user OSs, background processes support main apps.
Process Structure in Memory
A process is divided into four sections:
1. Text - Contains program code and current execution state
2. Data - Global and static variables
3. Heap - Dynamically allocated memory
4. Stack - Function parameters, return addresses, local variables
Multitasking, Multiprocessing & Threads
Multitasking:
- General term for handling multiple tasks concurrently.
Introduction to Processes in Operating Systems
Multiprocessing:
- Multiple processes run concurrently.
- Each has its own memory space.
Example: One process handles printing, another reads input.
Multithreading:
- A single process with multiple threads.
- Threads share the same address space.
Example: A program displays time while accepting user input.
Key Difference:
- Threads share memory (lightweight)
- Processes do not (heavier, more isolated)
Formal Definitions of a Process
- A process is an instance of a program in execution.
- Other definitions include:
* Asynchronous activity
* Focus of control
* Dispatchable unit
* Managed by Process Control Block (PCB)
Summary Table: Program vs Process vs Thread
Feature | Program | Process | Thread
-------------- | -------------- | ---------------- | ------------------------
Type | Passive entity | Active entity | Lightweight part of a process
Memory | Stored on disk | Own memory space | Shares memory with process
Execution | Not executed | Runs independently| Runs within a process
Example | .cpp file | [Link] when run | Clock display inside app