Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jun 2011 20:20:31 +0000
From:      rudot@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r223242 - soc2011/rudot/kern
Message-ID:  <20110614202031.0BB2B1065678@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rudot
Date: Tue Jun 14 20:20:30 2011
New Revision: 223242
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=223242

Log:
  basic virtual deadline

Modified:
  soc2011/rudot/kern/sched_fbfs.c

Modified: soc2011/rudot/kern/sched_fbfs.c
==============================================================================
--- soc2011/rudot/kern/sched_fbfs.c	Tue Jun 14 19:55:32 2011	(r223241)
+++ soc2011/rudot/kern/sched_fbfs.c	Tue Jun 14 20:20:30 2011	(r223242)
@@ -94,6 +94,7 @@
 	int		ts_cpticks;	/* (j) Ticks of cpu time. */
 	int		ts_slptime;	/* (j) Seconds !RUNNING. */
 	int		ts_flags;
+	int		ts_vdeadline;	/* virtual deadline. */
 	struct runq	*ts_runq;	/* runq the thread is currently on */
 #ifdef KTR
 	char		ts_name[TS_NAME_LEN];
@@ -131,6 +132,11 @@
  */
 static struct runq runq;
 
+/*
+ * Priority ratios for virtual deadline per nice value calculations.
+ */
+static int prio_ratios[PRIO_MAX - PRIO_MIN];
+
 static void
 setup_runqs(void)
 {
@@ -251,6 +257,13 @@
 static void
 sched_setup(void *dummy)
 {
+	int i;
+
+	prio_ratios[0] = 128;
+	for (i = 1; i < PRIO_MAX - PRIO_MIN; ++i) {
+		prio_ratios[i] = prio_ratios[i - 1] * 11 / 10;
+	}
+
 	setup_runqs();
 
 	if (sched_quantum == 0)
@@ -325,8 +338,18 @@
 	 * quantum (default quantum is 100ms).
 	 */
 	if (!TD_IS_IDLETHREAD(td) &&
-	    ticks - PCPU_GET(switchticks) >= sched_quantum)
+	    ticks - PCPU_GET(switchticks) >= sched_quantum) {
 		td->td_flags |= TDF_NEEDRESCHED;
+		ts->ts_vdeadline = ticks + sched_quantum *
+		    prio_ratios[td->td_proc->p_nice - PRIO_MIN] / 128;
+		
+		CTR4(KTR_SCHED, "timeslice fill: t: %d, i: %d, r: %d, d: %d",
+		    ticks, td->td_proc->p_nice - PRIO_MIN,
+		    prio_ratios[td->td_proc->p_nice - PRIO_MIN],
+		    ts->ts_vdeadline
+		);
+		    
+	}
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110614202031.0BB2B1065678>