Page 1 of 1
What kind of scheduler should I use?
Posted: Wed Nov 05, 2025 8:31 am
by GhostedGaming
So I want priority based scheduling and I'm currently in between making a priority based round robin or something else
here is the project the I'm making for multi-thread and scheduling:
https://github.com/GhostedGaming/eclipse-threader
here is my os:
https://github.com/GhostedGaming/eclipse-os
go to the overhaul branch
Re: What kind of scheduler should I use?
Posted: Wed Nov 05, 2025 11:39 am
by nullplan
So what is your question?
There are entire libraries on schedulers. Doubtful I could do an adequate job of summarizing, but you could do a prioritized round-robin like this:
- Every thread has a static priority and a dynamic priority.
- The static priority is the one that is set with nice() or setpriority() or such calls.
- When a thread becomes ready to run, its dynamic priority is initialized to the static priority.
- Each time the scheduler runs, the dynamic priority is incremented.
- The scheduler picks the thread with the highest dynamic priority.
- Whenever a task is picked, its dynamic priority is reset, whether or not it blocks.
This design has several important properties, the most important of which is freedom from starvation. Once a thread is ready to run, its dynamic priority starts growing, and must necessarily at some point become the highest in the system (in the absence of overflows, but that can be controlled with sensible limits on the underlying values).