socsvn commit: r223242 - soc2011/rudot/kern

rudot at FreeBSD.org rudot at FreeBSD.org
Tue Jun 14 20:20:33 UTC 2011


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
+		);
+		    
+	}
 }
 
 /*


More information about the svn-soc-all mailing list