KatInterview

Why One Process Never Gets CPU Time on a Two-Core System

System DesignModel answer
MediumModel answerSystem Designoperating-systemsschedulingconcurrency

Last updated

Given five identical CPU-bound processes on two cores where four run fairly and one runs never, pinpoint which OS subsystem is responsible and explain what can go wrong there.

Background

A developer notices something odd on a two-core machine running five identical, CPU-bound worker processes. Monitoring shows that four of the five workers share the two cores evenly — each gets roughly the same amount of CPU time. The fifth worker, however, shows zero CPU usage over an extended observation window. It is not crashing: it exists in the process table and has not exited.

Your Task

  1. Identify the OS component you would examine first to explain this behavior, and justify why that component — rather than memory management, the file system, or device drivers — is responsible for the outcome.

  2. List the specific conditions within that component that could cause exactly this symptom: four processes sharing CPU fairly while a fifth is permanently excluded.

  3. Distinguish between the case where the fifth process is runnable but never chosen versus the case where it is not runnable at all. Explain how you would tell the difference at runtime and what each case implies for the fix.

  4. Propose concrete remedies for each root cause you identify.

  5. Support your reasoning with a short simulation (code optional but encouraged) that reproduces the symptom and demonstrates how a fix restores fair scheduling.

What a complete answer looks like

  • Names the right component immediately and explains the reasoning in one or two sentences.
  • Covers at least four distinct failure modes within that component.
  • Mentions at least one diagnostic command or metric for each failure mode.
  • Describes the concept of aging and why it matters.
  • Includes working code (any language) that models strict-priority starvation and shows it disappearing when the scheduler policy changes.

Hints

Hint 1

Think about which part of the OS actually decides, tick by tick, which process occupies a core. Memory management and I/O subsystems don't make that call.

Hint 2

The four processes sharing time evenly is a clue: something is consistently ranking the fifth process lower. What properties attached to a process control that ranking?

Hint 3

Before assuming the scheduler is skipping the process unfairly, check whether the process is even eligible to run. A process blocked on a lock or I/O never reaches the run queue in the first place — and the fix is completely different.