Software-Engineering

Processes and Threads

1. What is a Process?

A process is an instance of a program in execution.

Key points:

A process contains:

Example:

Chrome Browser
 ├── Process 1: Tab A
 ├── Process 2: Tab B
 └── Process 3: GPU Process

If one process crashes, other processes usually continue running.


2. What is a Thread?

A thread is the smallest unit of execution inside a process.

Key points:

Threads share:

Threads have their own:

Threads are not independent like processes.


3. Who Runs on the CPU?

The CPU runs threads, not processes.


4. Relationship Between Process and Thread

Think of it like this:

Better definition:

A process provides memory and resources, while threads execute the program logic.


5. How Many Threads Can Run at the Same Time?

This depends on the number of CPU cores.

Single-core CPU:

Multi-core CPU:

If a system has:

4 CPU cores

Then:

4 threads can run truly in parallel

Example:

Only 8 threads execute simultaneously. The rest are waiting or scheduled.


6. Threads vs CPU Cores

Term Meaning
Thread Unit of execution
Core Physical execution unit
Parallelism Threads running at the same time
Concurrency Multiple threads making progress