Introduction to Processes & Threads
+50 XP RewardAn Operating System executes various programs. A program in execution is called a Process. A process is the unit of work in a modern time-sharing system.
What is a Process?
A process is more than the program code (text section). It also includes:- Program Counter: Current activity of the process.
- Stack: Temporary data (function parameters, return addresses, local variables).
- Data Section: Global variables.
- Heap: Dynamically allocated memory during runtime.
Processes vs Threads
A Thread is a basic unit of CPU utilization, comprising a thread ID, a program counter, a register set, and a stack. It shares with other threads belonging to the same process its code section, data section, and other operating-system resources, such as open files and signals.- Single-threaded Process: One thread of execution. Can only perform one task at a time.
- Multi-threaded Process: Multiple threads of execution. Can perform multiple tasks concurrently (e.g., rendering text while downloading a file).