Interactive OS Simulator
Experiment with the concepts below. Create Factories (Processes) and hire Workers (Threads). Observe how they share resources and how crashes affect them differently.
System Idle. Spawn a process to begin.
The "Factory" Metaphor
The Process is the Factory
Think of a process as a secured factory building. It has its own address, its own electricity (resources), and its own cafeteria (memory heap). It is isolated from other factories.
The Thread is the Worker
Threads are the workers inside the factory. They all share the same cafeteria and tools (memory), but each worker has their own task list (stack) and workbench (registers).
lightbulb Key Takeaway
- Workers (Threads) are fast to hire but if one sets the factory on fire (crashes), the whole building burns down.
- Factories (Processes) are expensive to build, but if one collapses, the factory next door is safe.
Memory Architecture
The most critical difference lies in how memory is handled. Processes are selfish; Threads are cooperative.
-
lock
Process: Private Address Space Processes cannot access each other's memory directly. Communication requires IPC (Inter-Process Communication) mechanisms like pipes, sockets, or shared memory files.
-
groups
Thread: Shared Address Space Threads within the same process share the Code, Data, and Heap segments. If one thread modifies a global variable, all other threads see the change instantly.
Visual Memory Map
Stack
Stack