Skip to the page

Operating systems · Scenario

The lab server crawls during an exam

The interviewer asks

During a lab exam, 60 students run their programs on one shared Linux server with 8 GB of RAM. After a few minutes everything becomes extremely slow: typing takes seconds to show. The CPU is mostly idle, but the disk is busy all the time. What's happening, and what would you do?

Then

Follow-ups the interviewer asks next

  1. What would you check first, and with which commands?
  2. Why is the CPU idle if everyone is waiting?
  3. What would an old-style OS do when it sees low CPU use, and why does that make it worse?
  4. What can you do right now, during the exam?
  5. What would you change before the next exam?
  6. What are the working set and page-fault frequency ideas?

The answer

What a strong answer covers

  • Clarify: when it started, whether it's all users or one, and what's running.
  • Check: free -h (RAM and swap), vmstat 1 (the si and so columns show swapping), top sorted by memory. Low CPU, high disk and heavy swap together mean thrashing.
  • Thrashing: the programs together need more memory than RAM can hold, so the system spends its time moving pages between RAM and disk instead of running code. Every process keeps waiting on page faults, so the CPU sits idle.
  • Old schedulers saw low CPU use and let more programs in, which made it worse; that's the classic thrashing loop.
  • Right now: stop the biggest memory users (a stuck program, an extra IDE), ask students to close what they don't need, or limit how many run at once.
  • Before next time: cap memory per program (for example -Xmx256m for Java, or per-user limits with cgroups), add RAM, split students across servers, and use lighter tools.
  • Working set: the pages a process is actively using; if the sum of working sets is bigger than RAM, suspend some processes. Page-fault frequency: give a process more frames when its fault rate is high, take some away when it's low.

The red pen

Common traps

Avoid:"the CPU is slow, buy a faster CPU"; "add more swap" as the fix (it only makes thrashing last longer); restarting the server without finding what uses the memory.

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview