Interview Q&A / Operating Systems
Operating Systems interview questions
Processes, threads, scheduling, memory and deadlocks, in plain words.
Prefer rapid revision? Practise Operating Systems short interview answers →
- What is context switching in an operating system?
Context switching is when the OS pauses the process or thread running on a CPU, saves its state (registers, program counter, stack pointer) in its control block, and loads the saved state of another one so it can continue. It lets many programs share one CPU, but each switch is pure overhead.
BeginnerIn-depth3 min read - For burst times 24, 3 and 3 (all arriving at time 0), what is the average waiting time under non-preemptive SJF?
SJF runs the shortest burst first: P2, P3, then P1. Waiting times are P2 0, P3 3, P1 6, so the average is (0 + 3 + 6) / 3 = 3 ms, which is the minimum possible.
BeginnerQuick answer1 min read - Three processes with burst times 24, 3 and 3 arrive together. What is the average waiting time under FCFS?
Run in arrival order P1, P2, P3. Waiting times are 0, 24 and 27, so the average is (0 + 24 + 27) / 3 = 17 ms. Waiting time is the time a process spends in the ready queue before it gets the CPU.
BeginnerQuick answer1 min read - What are the states of a process in its life cycle?
A process moves through new, ready, running, waiting (blocked) and terminated. The scheduler moves it between ready and running; I/O or events move it between running and waiting.
BeginnerQuick answer1 min read - What is the difference between turnaround time, waiting time and response time?
Turnaround time is completion minus arrival. Waiting time is turnaround minus burst, the total time spent in the ready queue. Response time is the time from arrival to the first time the process gets the CPU.
BeginnerQuick answer1 min read