Implementing stride scheduling in C++
This medium-difficulty coding problem asks you to implement a deterministic, proportional-share CPU scheduler—a core operating-systems concept used to allocate processor time fairly among competing processes. You must correctly handle process arrival, departure, and the core scheduling loop under tight performance constraints.
The challenge lies in combining three things: computing stride values inversely proportional to ticket allocations, efficiently tracking and updating pass values for eligible processes, and handling both the logical correctness of tie-breaking (by lowest pid) and the performance requirements of up to 1 million scheduling ticks. A well-designed solution will use an appropriate data structure to keep the minimum-pass process accessible in logarithmic time, while managing the state transitions as processes arrive and leave.
- Priority-queue and heap operations
- Process state management and invariant tracking
- Integer arithmetic and stride computation
- Edge cases: empty scheduler, tie-breaking rules, initial pass assignment