Master the fundamental concepts of process management through this focused micro-challenge.
Round-robin scheduling gives every ready process a fixed quantum before moving it to the back of the queue. No process monopolizes the CPU while others sit in the ready state. The policy is predictable: throughput is fine for interactive workloads, and starvation is impossible as long as the queue drains.
Key pieces of a RR scheduler:
For example, with quantum 10 ms and three processes A, B, C each needing 30 ms of CPU, the run order is A(10), B(10), C(10), A(10), B(10), C(10), A(10), B(10), C(10). Total completion is 90 ms of CPU time spread across nine slices.
Round-robin is the ancestor of every time-sharing scheduler still in production, from early Unix to Windows' quantum-based dispatcher, and picking the quantum wrong is a real tuning problem: too short and context-switch overhead dominates (as seen in early VAX/VMS tuning guides), too long and interactive shells feel laggy. This task's turnaround/waiting/response metrics are exactly what tools like perf sched report when engineers diagnose scheduler fairness.
Before you call the implementation done, walk failure modes on purpose. Test empty structures, single-element edge cases, maximum concurrency, and errno paths that must not crash the program. OS code usually fails in production when happy-path tests pass but invariants break under contention or memory pressure.
Keep structures small and name fields after kernel counterparts when possible. That lets you read man pages and kernel source side by side while you work. Print observable events during development; remove noisy logs once tests pass reliably.
You will build the ready queue, timer interrupt handler, and preemption path that rotates processes. Understanding slice boundaries matters because every real OS scheduler (Linux CFS still uses the same preemption idea) depends on correct quantum accounting.
Implement a round-robin scheduler with configurable time quantum.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github