SDE-1 All-In Guide
CS Fundamentals: Track B

Operating systems

Processes, scheduling, deadlock, memory and the Linux layer under your containers, split into what SDE-1 asks and what waits.

The operating system is the layer that shares one CPU, one memory space and one disk between many programs. Interviewers ask about it because every backend bug eventually lands there: a slow request, a full connection pool, a process killed at 3 a.m.

It is also the vocabulary for concurrency and for every container question. Read this page in weeks 1 to 2, then keep answering the questions out loud until they are boring.

Priority for SDE-1

The must list is short: process vs thread, context switch, scheduling, synchronisation, deadlock, paging and the page fault walk. Page cache internals, cgroups, the OOM killer and io_uring are SDE-2 reading. Skip them until you have an offer.

SDE-1 scope vs SDE-2 scope

AreaSDE-1 mustSDE-2 later
Processes and threadsWhat is shared, what is private, why a thread is cheaperThread pool sizing under real load, stack growth
CPU schedulingFCFS, SJF, round robin, and the waiting-time arithmeticCFS and EEVDF, nice values, CPU affinity
SynchronisationMutex vs semaphore, race condition, condition variableFutex internals, lock contention profiling
DeadlockThe four Coffman conditions, and how to break eachLock graphs in production, deadlock detection at scale
MemoryPaging, page table, TLB, page fault, virtual vs physicalHuge pages, NUMA, memory fragmentation
Files and I/Owrite, fsync, buffered vs direct I/O, sequential vs randomPage cache reclaim, readahead, io_uring, kernel bypass
Linux basicsfork, execve, signals, exit codes, kill -9cgroup limits, OOM killer, namespaces at depth
ContainersA container is a process with namespaces and cgroup limitsImage layers, runtime isolation, seccomp profiles

Roadmap

Stage 1: the basics (weeks 1 to 2)

Read OSTEP chapters on processes, threads, scheduling, locks and memory. Do not read the whole book. Five chapters are enough to answer everything in this stage: processes, threads, CPU scheduling, address spaces, and paging.

Draw the process state diagram once, by hand. Then draw a page table walk for a two-level table. Those two drawings carry most of the round.

Stage 2: interview core (weeks 3 to 7)

This stage runs beside Ledgerline, so use the build as your examples. When you add ordered locking in week 3, write down what would deadlock without it. When you rely on Postgres for durability, write down what a crash between the write and the fsync would lose.

Answer the SDE-1 questions below out loud, recorded, once a week. Reread nothing. If an answer stalls, note the gap and fix only that gap.

Stage 3: SDE-2 depth (weeks 8 to 15, optional now)

The second half of the fundamentals block has room for the parts an SDE-2 interview probes: how the page cache behaves under write load, what a cgroup memory limit actually does, when the OOM killer fires, and why io_uring exists.

Treat this as reading, not drilling. If a subject from stage 2 is still shaky at week 8, spend the time there instead.

Core topics, in order

TopicWhat to be able to explainLevel
Process vs threadAddress space, file descriptors and signal handlers are per process; heap and code are shared by threads.SDE-1 must
Context switchSaving one thread's registers and stack pointer, loading another's, and why the TLB reload makes it costly.SDE-1 must
CPU schedulingRun FCFS, SJF and round robin over three jobs by hand and compare average waiting time.SDE-1 must
SynchronisationA mutex guards a critical section; a semaphore counts permits; a condition variable waits for a state change.SDE-1 must
DeadlockMutual exclusion, hold and wait, no preemption, circular wait. Break one and the deadlock cannot form.SDE-1 must
PagingVirtual pages map to physical frames through a page table; the TLB caches recent translations.SDE-1 must
Page faultThe CPU traps, the kernel finds or creates the frame, updates the table, reloads the instruction.SDE-1 must
Virtual memoryEach process sees a private, contiguous address space that may exceed physical RAM.SDE-1 must
File systems and I/Owrite copies into the page cache; fsync forces it to disk. Sequential beats random.SDE-1 nice
SignalsAsynchronous notifications: SIGTERM asks, SIGKILL cannot be caught, SIGSEGV means a bad access.SDE-1 nice
fork and execvefork clones the process, execve replaces its image. A shell is a loop of both plus wait.SDE-1 nice
Page cache behaviourReads and writes hit RAM first; dirty pages flush later. This hides disk latency and sets your durability window.SDE-2 later
cgroups and OOMA cgroup caps memory for a group of processes; going over the limit triggers reclaim, then the OOM killer.SDE-2 later
ContainersNamespaces hide PIDs, mounts and network; cgroups cap CPU and memory. There is no virtual machine.SDE-2 later
io_uring and kernel bypassSubmission and completion queues avoid a syscall per operation; bypass skips the kernel entirely.SDE-2 later

Four commands worth typing once

You do not need to be a systems programmer for SDE-1. You need to have seen these run once.

  • ps -eLf shows threads as separate rows under one process. That is the process vs thread answer, visible.
  • strace -f -e trace=openat,write,fsync ./yourserver shows every file call your program makes. Point at the fsync.
  • cat /proc/<pid>/status shows voluntary and involuntary context switches, plus the resident set size in kB.
  • free -m separates total, used, buffered and cached. The cached column is the page cache, not wasted memory.

The page cache is not a leak

If free shows most memory as cached, nothing is wrong. The kernel reclaims that memory when a process needs it. Saying this out loud is a small, credible signal.

Resources

Learn

Practice

Long-form

Questions to answer out loud

Answer each in 60 to 90 seconds, recorded.

  1. What does a thread share with its process, and what does it not share?
  2. Why is a context switch expensive? Name the two costs.
  3. Run FCFS and round robin over three jobs and say which has the lower average wait.
  4. Why does SJF need a prediction, and what does the scheduler use instead?
  5. What are the four Coffman conditions? Break one of them in a sentence.
  6. Mutex or semaphore for a pool of 5 database connections? Why?
  7. What happens on a page fault, step by step?
  8. What is the TLB, and what happens on a TLB miss?
  9. What is the difference between a process and a container?
  10. What does fsync guarantee that write does not?

SDE-2 questions

  1. How does the page cache change the cost of a 4 kB random write versus a 1 MB sequential one?
  2. What happens when a container crosses its cgroup memory limit?
  3. Why can the OOM killer pick the wrong process, and how do you influence its choice?
  4. When is io_uring worth the complexity over a thread pool doing blocking reads?
  5. How do you find which process is causing involuntary context switches on a box?

How this shows up in your projects

  • Ledgerline, ordered locking. You take row locks in account ID order to prevent the circular wait. That is Coffman condition four, removed in code.
  • Ledgerline, fsync and durability. Postgres commits with fsync by default. The gap between write and fsync is the window where a power cut loses the last transfer.
  • Ledgerline, connection pools. Each request holds a connection, which is a thread plus a socket plus kernel buffers. An exhausted pool is a scheduling and blocking story, not just a config value.
  • Logsmith, append-only files. Sequential appends land in the page cache and flush later. Your three fsync modes are a direct trade of throughput against the durability window.

Common mistakes

  • Answer with the mechanism, then the name. "The CPU traps and the kernel loads the frame" before "demand paging".
  • Use one project example per answer, in one sentence.
  • Draw the page table walk on paper until you can do it without notes.
  • Say plainly what you have not used. Claiming cgroup tuning you never did is worse than a gap.

On this page