A process is a running program with its own memory space.

A thread is a lightweight execution path within a process, sharing memory.


Process vs Thread

Aspect Process Thread
Memory Isolated, own address space Shared within process
Creation cost Heavy (new memory, resources) Light (shares parent's resources)
Communication IPC (pipes, sockets, shared memory) Direct memory access
Crash impact Isolated — other processes unaffected Can crash entire process
Use case Isolation, security, stability Performance, shared state

CPU Clock Speed (Hz)

Hz measures clock cycles per second — not threads or instructions.


The Instruction Cycle

Every instruction flows through stages:

Stage What Happens
Fetch Get instruction from memory
Decode Figure out what the instruction means
Execute Perform the operation (ALU, memory access)
Write-back Store the result

Pipelining

Modern CPUs overlap stages of different instructions:

Clock:    1     2     3     4     5     6
Inst 1: [Fetch][Decode][Exec][Write]
Inst 2:       [Fetch][Decode][Exec][Write]
Inst 3:             [Fetch][Decode][Exec][Write]

Result: Complete one instruction per cycle once pipeline is full.