Multitasking

Definition

Multitasking means the operating system can manage multiple programs or applications at the same time.

The OS rapidly switches the CPU between programs.

Because this switching happens very fast, it feels like all programs are running together.

In simple words:

Multiple applications are active at the same time.


Example

You are using:

All of them appear to run together.

This is Multitasking.

Key Points


Multiprocessing

Definition

Multiprocessing means using multiple CPU cores or processors to run multiple processes.

Here, work can actually happen at the same time on different CPU cores.

Unlike basic multitasking, multiprocessing can provide true parallel execution.

In simple words:

Multiple CPU cores execute multiple processes in parallel.


Example

Suppose your computer has:

CPU = 8 Cores

The OS can run:

These can execute at the same time on different cores.

This is Multiprocessing.

Key Points


Multithreading

Definition

Multithreading means running multiple threads inside the same process.

Threads share the same memory and resources of that process.

Each thread can still execute independently.

In simple words:

One application is split into multiple smaller execution paths.


Example

Chrome is one process.

Inside Chrome:

These threads work together.

This is Multithreading.

Key Points


Comparison

Multitasking Multiprocessing Multithreading
Multiple applications run together. Multiple processes execute on multiple CPU cores. Multiple threads execute within the same process.
OS-level feature. Hardware + OS feature. Process-level feature.
May use one or many CPU cores. Requires multiple CPU cores/processors for true parallelism. Threads share the same memory space.
Example: Chrome + VS Code + Spotify. Chrome on Core 1, VS Code on Core 2. UI Thread + Network Thread + Rendering Thread in Chrome.
--- # Relationship This picture helps remember everything: ```plain text Operating System │ ├── Multitasking │ ├── Chrome (Process) │ ├── VS Code (Process) │ └── Spotify (Process) │ └── Chrome (One Process) ├── UI Thread ├── Network Thread ├── Rendering Thread └── JS Thread ``` - **Multitasking** → Multiple applications/processes. - **Multithreading** → Multiple threads inside one application. - **Multiprocessing** → Multiple CPU cores executing processes in parallel. --- # One thing that interviewers like to ask > **Can a computer do all three at the same time?** **Yes.**

Example:

All three concepts can exist at the same time.

This is usually all that's expected for backend interviews. The important thing is to understand what is "multiple" in each term: