Operating Systems Interview
Every question shows beginner, strong and expert answers, green and red flags, follow-ups and a scenario. Memorised one-liners are not rewarded: the strong answer names the mechanism, the trade-off and the failure implication.
ProcessesIntermediate
Process vs thread
What is the difference between a process and a thread? Go beyond "a thread is a lightweight process".
ProcessesBeginner
What a process actually is
What is a process, concretely? What does the kernel keep for it, and how is it different from the program on disk?
ProcessesIntermediate
fork, exec and why they are separate
Walk me through what happens when a shell runs `ls > out.txt`. What do fork and exec each do, and why are they two calls instead of one?
SchedulingAdvanced
The real cost of a context switch
What does a context switch actually cost, and why is the answer "more than saving the registers"?
SchedulingIntermediate
Why a scheduler exists
Why does the OS need a scheduler at all, and what is it optimising for? What could go wrong with the simplest scheme you can think of?
Threads & asyncBeginner
Concurrency vs parallelism
What is the difference between concurrency and parallelism? Can you have one without the other, and why does the distinction matter for bugs?
Threads & asyncIntermediate
How an event loop works
Explain how an event loop lets one thread serve thousands of connections. What can it not do, and how does that failure look?
Threads & asyncAdvanced
The Python GIL
What is Python’s GIL, what does it actually prevent, and when does multithreading in Python still help?
Threads & asyncAdvanced
Async I/O vs threads
When would you choose async I/O over threads, and when the reverse? What does each cost?
MemoryIntermediate
Why virtual memory exists
Why does virtual memory exist? List the problems we would have without it, and then the costs it introduces.
MemoryIntermediate
Page faults
What is a page fault? Are all page faults bad? How would you find out whether a slow process is suffering from them?
MemoryAdvanced
The TLB and application performance
What is the TLB, why does it exist, and when does an application programmer need to care about it?
MemoryBeginner
Stack vs heap
Where do local variables live and where do objects live? Why does the split exist, and what does each choice cost?
Files & I/OIntermediate
What a system call is and costs
What is a system call, what happens on the CPU when you make one, and what does it cost? When does the number of syscalls become the bottleneck?
Files & I/OIntermediate
What a file descriptor really is
What is a file descriptor, really? What is descriptor 3, and why are sockets, pipes and epoll instances also descriptors?
Files & I/OAdvanced
select, poll, epoll and kqueue
How can one thread wait on 10,000 sockets without spinning? Compare select, poll, epoll and kqueue, and say what none of them can do.
ConcurrencyIntermediate
Anatomy of a race condition
Two threads each increment a shared counter 1,000 times and the final value is less than 2,000. Explain exactly what happened at the instruction level, and give three different fixes with their costs.
ConcurrencyIntermediate
Deadlocks: conditions, detection, prevention
What is a deadlock, what are the four conditions, and how would you detect one in a running service — as opposed to a service that is merely slow?
ConcurrencyIntermediate
Mutex vs semaphore
What is the difference between a mutex and a semaphore? Is a binary semaphore the same thing as a mutex? When would you use each?
ContainersIntermediate
Container vs virtual machine
What is the difference between a container and a virtual machine? If a container has no kernel of its own, what is actually isolating it?
ProductionAdvanced
Diagnosing EMFILE
A service starts logging `EMFILE: too many open files` after about a day of uptime. How do you approach it? Is raising the limit the fix?
ProductionAdvanced
The four meanings of 100% CPU
A process is at 100% CPU. What are the different things that could mean, and how do you tell them apart in the first five minutes?
ProductionAdvanced
Is it a leak? RSS growth diagnosed
The RSS of a long-running service grows for days until it is OOM-killed. How do you decide whether it is a leak, where the memory is, and what to do about it?
OS + NetworkingIntermediate
Walk me from send() on one machine to recv() on another
Process A calls `send(sock, buf, 1024)` and process B, on another host, is blocked in `recv()`. Describe every step, every copy, and every place the bytes can wait.
OS + NetworkingAdvanced
How does one server handle 10,000 (or 100,000) concurrent connections?
Explain what limits a server’s concurrent connections and how a modern server reaches 100K. Be specific about what each connection costs in the kernel and in the process.
OS + NetworkingIntermediate
Blocking servers vs event-driven servers
Compare a thread-per-connection server with an event-driven one. What is actually blocking, in the kernel, when a thread "blocks"? When is each design the right one?
OS + NetworkingAdvanced
What is backpressure, physically?
A producer sends faster than a consumer can handle. Explain, layer by layer, what happens in the kernel and on the network — and why a slow consumer can freeze a fast producer.
OS + NetworkingAdvanced
What does "zero-copy" actually eliminate?
Serving a static file over a socket: count the copies and mode switches in the naive `read()` + `send()` loop, then explain what `sendfile()`, `mmap()` and `splice()` change and when they matter.
OS + NetworkingExpert
A user in Warsaw waits 3 seconds. Where did the time go?
A user in Warsaw loads a page from your service hosted in Virginia and it takes 3 seconds; your server metrics show 30 ms of handler time. Walk through every layer where those 3 seconds could be, name the domain that explains each, and say how you would measure it.