c2cedge
CS Fundamentals · A — Operating Systems

Operating Systems & Processes

The OS is the manager between your program and the hardware. Interviews start with what a process is and how the OS juggles many at once.

Test weight: Very highAsked by: TCS, Infosys, WiproDifficulty: Easy–Medium

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

StateMeaning
Newbeing created
Readywaiting for the CPU
Runningexecuting on the CPU
Waiting / Blockedwaiting for I/O or an event
Terminatedfinished 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?'
  1. Define both: a program is passive code on disk; a process is that program actively executing.
  2. Add the key distinction: a process has its own address space, registers and state, tracked by a PCB.
  3. Close with an example: opening two windows of the same editor is one program, two processes.
Worked example
'What happens during a context switch, and why is it costly?'
  1. The OS saves the current process's CPU registers and program counter into its PCB.
  2. It loads the next process's saved state from that process's PCB and resumes it.
  3. It is costly because no useful work happens during the switch — it is pure overhead, plus cache effects.
⚠ 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.
Practice this — take a timed mock →
1,300+ questions, scored, with a weak-area report.
Know who's ready. Not who finished.
HomeLibraryPrivacyTerms