Master the fundamental concepts of build a mini kernel through this focused micro-challenge.
The mini-kernel scheduler ties PIT ticks to a ready queue of tasks. On each tick, decrement quantum, preempt if zero, and call your assembly context switch.
Maintain:
For example, three kernel tasks with quantum 5 ticks rotate in ABCABC order if all remain runnable.
Round-robin is exactly how early Unix and the original Linux scheduler shared the CPU before the O(1) scheduler and later Completely Fair Scheduler (CFS) replaced it with more sophisticated fairness models. Forgetting to reset a task's time slice before re-enqueuing it is a bug that lets one task monopolize the CPU forever while every other READY task starves in the queue.
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 integrate timer IRQ, scheduling decisions, and switch_to. The task asks you to print each dispatch with task id and remaining quantum for debugging.
Implement a round-robin scheduler in C.
Requirements:
Test:
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