Looking through the scheduler source code (2.6.34, kernel/sched.c), I can see how the “pluggable” schedulers are used, and I believe I understand the interface to be implemented. What I don’t understand yet is how to get my code built into the kernel. At the very least, pointers to other sites would be appreciated.
Right now, I’m grepping for SCHED_FIFO, SCHED_RR, and SCHED_NORMAL in the kernel source tree, so really I’m looking for a more insightful way to look at it 🙂
EDIT: As some background, I’m very familiar with the FreeBSD scheduler (and the FreeBSD kernel in general), so I’m not looking for pointers on how to do process/thread level scheduling. I’m looking for a way to add my own scheduler alongside the normal linux schedulers (similar to SCHED_FIFO).
EDIT #2: The BFS pointer below is a good start, but it still rips CFS out of the kernel. sched.c now looks like:
#ifdef CONFIG_SCHED_BFS
#include "sched_bfs.c"
#else
// original sched.c
#endif // CONFIG_SCHED_BFS
I’d love to see an answer or a pointer on how to do this a little better (ie, keep CFS, at least for right now).
EDIT #3: I’ve answered my own question below, as I think I’ve figured it out.
I’ve figured out the answer to my question, so I thought I’d add it here. Below is the patch that will add a new scheduler to the 2.6.34 vanilla kernel. Right now, I’ve only compiled the kernel. I fully expect running a system with this EXACT patch will cause it to crash — so use at your own risk 🙂