git: kernel - Add batch heuristic to scheduler and refactor some of the code 1/2

Matthew Dillon dillon at
Thu Feb 17 00:58:31 PST 2011

commit 52cac9fb50c0a148e396b28f986615dfd7a0ee95
Author: Matthew Dillon <dillon at>
Date:   Thu Feb 17 00:47:58 2011 -0800

    kernel - Add batch heuristic to scheduler and refactor some of the code 1/2
    * Split the dynamic priority mechanism into two stages:
    * Stage 1 is the normal dynamic priority mechanism which reacts very quickly
      to cpu hogging vs idle / not hogging.
    * Stage 2 is a long-term (30-second) batch operations detector which de-tunes
      the estcpu calculation based on how long the process has been acting
      batch-like or non-batch-like.  estcpu is detuned up to 50% for processes
      considered to be fully interactive.
    * Newly forked processes are placed two queue slots higher (less desireable)
      than their parent in stage 1.  If they aren't batch they will quickly
    * Newly forked processes are given a batch heuristic value that is mid-range
      for stage 2 and must prove themselves one way or the other.
    * 'ps -o batch -axl' can be used to see the batch heuristic.  ps will display
      it as a value between 0 and 11 for the moment.
      The idea here is for something like firefox and the X server to remain
      interactive even if they use a lot of cpu, while something like a parallel
      buildworld winds up remaining batch-like because the core processes are

Summary of changes:
 sys/kern/kern_exit.c    |    4 +
 sys/kern/kern_kinfo.c   |    2 +-
 sys/kern/usched_bsd4.c  |  213 ++++++++++++++++++++++++++++-------------------
 sys/kern/usched_dummy.c |    4 +-
 sys/sys/usched.h        |    4 +-
 5 files changed, 137 insertions(+), 90 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list