An operating system (OS) is the software layer that manages a computer's hardware and provides services to programs. It allocates the CPU, memory and devices, and it isolates programs from one another. Almost every OS interview opens here: what an OS does, and what exactly a process is.
What an OS does
The OS is a resource manager and an abstraction layer. It manages the processor (scheduling), memory (allocation and protection), files (storage) and devices (I/O), while hiding hardware details behind clean interfaces like files and system calls.
Process vs program
- A program is passive — code sitting on disk.
- A process is a program in execution — an active entity with its own memory, registers and program counter.
- One program can spawn many processes (open the same app twice).
- Each process is tracked by a Process Control Block (PCB): its ID, state, registers, memory map and open files.
The five process states
| State | Meaning |
|---|---|
| New | being created |
| Ready | waiting for the CPU |
| Running | executing on the CPU |
| Waiting / Blocked | waiting for I/O or an event |
| Terminated | finished execution |
⚡ The edge
- Frame a process as a program plus its execution context — memory (code, data, heap, stack), CPU registers, program counter and OS bookkeeping (the PCB).
- A context switch is the OS saving one process's state into its PCB and loading another's. It is pure overhead, which is why too many switches hurt performance.
Worked example
In an interview: 'What is the difference between a process and a program?'
- Define both: a program is passive code on disk; a process is that program actively executing.
- Add the key distinction: a process has its own address space, registers and state, tracked by a PCB.
- Close with an example: opening two windows of the same editor is one program, two processes.
Answer: A program is passive code; a process is a program in execution with its own context and PCB.
Worked example
'What happens during a context switch, and why is it costly?'
- The OS saves the current process's CPU registers and program counter into its PCB.
- It loads the next process's saved state from that process's PCB and resumes it.
- It is costly because no useful work happens during the switch — it is pure overhead, plus cache effects.
Answer: The OS swaps the running process by saving/loading PCB state; it is overhead, doing no real work.
⚠ Watch out
- Don't equate 'program' and 'process' — the distinction (passive vs executing) is the whole question.
- A context switch is overhead, not progress; more switches mean more wasted CPU time.
- The PCB stores process state; it is not the process's actual memory/data itself.