← Lessons

quiz vs the machine

Platinum1800

Concurrency

Testing with Controlled Scheduling

Take control of the scheduler to drive specific interleavings on purpose.

5 min read · advanced · beat Platinum to climb

Why control the scheduler

Stress tests leave interleavings to chance. A controlled scheduler intercepts every blocking and synchronization point so the test, not the operating system, decides which thread runs next.

How it explores schedules

With control over thread choice the framework can systematically enumerate interleavings:

  • at each scheduling point it records the set of runnable threads
  • it picks one, runs to the next point, and records the choice
  • on replay it can take a different branch to cover a new ordering

Bounding the search, for example by limiting preemptions, keeps the space tractable while still hitting most real bugs.

Reproducibility for free

Because the test owns scheduling, any failure is fully reproducible by replaying the recorded choices, turning flaky concurrency bugs into deterministic ones.

Key idea

A controlled scheduler intercepts synchronization points so a test drives interleavings systematically, making failures reproducible and exploring schedules that random runs rarely reach.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a controlled scheduler take over?

2. Why are failures reproducible under controlled scheduling?