🧠 What is Multiprocessing?
Multiprocessing refers to a computer system with two or more CPUs (or cores) that can execute instructions simultaneously.
In simple terms:
Instead of one CPU switching between programs, you have multiple CPUs running programs in parallel.
🧱 Multiprocessing = True Parallelism
| Feature | Description |
|---|---|
| 🧩 Hardware-level | Requires multiple processors or CPU cores |
| 🚀 Runs multiple processes at once | Not just switching (like multiprogramming), but actual parallel execution |
| 🎯 Improves speed, reliability, and throughput | More power, less waiting |
⚙️ Types of Multiprocessing Systems
| Type | Description | Example |
|---|---|---|
| Symmetric Multiprocessing (SMP) | All CPUs are equal; OS assigns tasks dynamically | Most modern desktops, servers |
| Asymmetric Multiprocessing (AMP) | One master CPU controls others (often in embedded systems) | Real-time or older systems |
🔁 Multiprocessing vs Multiprogramming
| Feature | Multiprogramming | Multiprocessing |
|---|---|---|
| 🧠 Concept | One CPU switches between tasks | Multiple CPUs work at the same time |
| ⚙️ Execution | Concurrent (via switching) | Parallel (truly simultaneous) |
| 🛠️ Hardware | Single CPU needed | Multiple CPUs/cores required |
| 🚀 Goal | Maximize CPU utilization | Maximize performance and speed |
| 🎯 Example | Running Excel and Word on one core | Running one on core 1 and one on core 2 at the same time |
📦 Why Multiprocessing?
| Benefit | Why It Matters |
|---|---|
| 🧠 True parallelism | Multiple programs run at once |
| 🚀 Faster execution | Split workloads (e.g., multithreaded apps) |
| 🔁 Improved responsiveness | One stuck task doesn’t affect others |
| 🛡️ Fault tolerance | Some systems can survive if one processor fails |
🧪 Real-World Examples
| System | Multiprocessing |
|---|---|
| Linux / Windows | Uses all available CPU cores for processes |
| Java JVM | Threads can run in parallel on multiple cores |
| Databases | Parallel query execution |
| Video games | Physics, AI, rendering on separate cores |
⚙️ How OS Handles Multiprocessing
-
The OS must have a scheduler that assigns tasks to available CPUs.
-
It must manage:
-
Concurrency
-
Locks/semaphores
-
Load balancing
🧠 Interview-Ready Definition:
Multiprocessing is the use of two or more processors (or cores) within a single computer system to execute multiple processes simultaneously. It enables true parallel processing, resulting in faster execution, higher system throughput, and better responsiveness.