title: How to create a new Linux kernel scheduler
body: <p>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.</p>
  
  <p>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 :-)</p>
  
  <p>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).</p>
  
  <p>EDIT #2:  The BFS pointer below is a good start, but it still rips CFS out of the kernel.  sched.c now looks like:</p>
  
  <pre><code>#ifdef CONFIG_SCHED_BFS
  #include "sched_bfs.c"
  #else
     // original sched.c 
  #endif // CONFIG_SCHED_BFS
  </code></pre>
  
  <p>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).</p>
  
  <p>EDIT #3:  I've answered my own question below, as I think I've figured it out.</p>