Master the fundamental concepts of process management through this focused micro-challenge.
Static priority scheduling runs the highest-priority ready process first. A low-priority task can wait forever if higher-priority work never blocks. That is starvation, and it shows up in production when a background indexer never runs because foreground tabs keep spawning runnable threads.
Aging raises a waiting process's effective priority over time:
For example, a batch job at base priority 10 that waits 200 ticks with aging every 40 ticks gains 5 levels and eventually preempts a sleeping high-priority task.
Unbounded priority scheduling caused the Mars Pathfinder's real 1997 priority-inversion bug, where a low-priority task holding a mutex blocked a high-priority one until a watchdog reset the system; VxWorks and most RTOS schedulers now ship priority inheritance specifically because of that incident. The aging mechanism you implement here is the same fix Linux's O(1) scheduler and Windows' dynamic priority boost used before CFS replaced them.
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 add priority comparison on enqueue and an aging function that prevents indefinite starvation. The task requires you to log preemption decisions so you can see when aging, not raw priority, wins the CPU.
Implement a priority-based scheduler with aging to prevent starvation.
Requirements:
Test scenarios:
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