Index: linux-2.6.10-s10.3/kernel/sched.c
===================================================================
--- linux-2.6.10-s10.3.orig/kernel/sched.c	2005-01-14 19:05:27.872527680 +1100
+++ linux-2.6.10-s10.3/kernel/sched.c	2005-01-14 19:10:25.073346288 +1100
@@ -561,8 +561,8 @@
 }
 
 /*
- * slice - the duration a task runs before getting requeued at it's best
- * priority and has it's burst decremented.
+ * slice - the duration a task runs before getting requeued at its best
+ * priority and has its burst decremented.
  */
 static unsigned int slice(task_t *p)
 {
@@ -606,11 +606,25 @@
 	if (used_slice < first_slice)
 		return prio;
 	prio += 1 + (used_slice - first_slice) / rr;
-	if (prio >= MAX_PRIO - 1) {
+	if (prio >= MAX_PRIO - 1)
 		prio = MAX_PRIO - 1;
+	return prio;
+}
+
+static void continue_slice(task_t *p)
+{
+	unsigned long total_run = NS_TO_JIFFIES(p->totalrun);
+
+	if (total_run >= p->slice) {
 		p->totalrun = 0;
+		dec_burst(p);
+	} else {
+		unsigned int remainder;
+		p->slice -= total_run;
+		remainder = p->slice % rr_interval(p);
+		if (remainder)
+			p->time_slice = remainder;
 	}
-	return prio;
 }
 
 /*
@@ -621,38 +635,39 @@
 static void recalc_task_prio(task_t *p, unsigned long long now)
 {
 	unsigned long sleep_time = ns_diff(now, p->timestamp);
-	unsigned int rr = rr_interval(p);
-	unsigned int best_burst = burst(p);
-	if (p->flags & PF_FORKED || sched_compute ||
-		(NS_TO_JIFFIES(p->runtime + sleep_time) < rr)) {
-			unsigned long ns_totalrun = p->totalrun + p->runtime;
-			unsigned long total_run = NS_TO_JIFFIES(ns_totalrun);
+
+	p->totalrun += p->runtime;
+	if (NS_TO_JIFFIES(p->totalrun) >= p->slice - 1 &&
+		NS_TO_JIFFIES(sleep_time) < p->slice) {
 			p->flags &= ~PF_FORKED;
-			if (p->slice - total_run < 1) {
-				p->totalrun = 0;
-				dec_burst(p);
-			} else {
-				unsigned int intervals = total_run / rr;
-				unsigned int remainder;
-				p->totalrun = ns_totalrun;
-				p->slice -= intervals * rr;
-				if (p->slice <= rr) {
-					p->totalrun = 0;
-					dec_burst(p);
-				} else {
-					remainder = p->slice % rr;
-					if (remainder)
-						p->time_slice = remainder;
-				}
-			}
-	} else {
-		if (NS_TO_JIFFIES(p->totalrun) > (best_burst - p->burst) * rr)
 			dec_burst(p);
-		else if (!(p->flags & PF_UISLEEP || p->totalrun))
+			goto new_slice;
+	}
+
+	if (p->flags & PF_FORKED) {
+		continue_slice(p);
+		p->flags &= ~PF_FORKED;
+		goto out;
+	}
+
+	if (sched_compute) {
+		continue_slice(p);
+		goto out;
+	}
+
+	if (sleep_time >= p->totalrun) {
+		if (!(p->flags & PF_UISLEEP))
 			inc_burst(p);
-		p->runtime = 0;
-		p->totalrun = 0;
+		goto new_slice;
 	}
+
+	p->totalrun -= sleep_time;
+	continue_slice(p);
+	goto out;
+new_slice:
+	p->totalrun = 0;
+out:
+	return;
 }
 
 /*
@@ -2154,6 +2169,7 @@
 		dec_burst(p);
 		p->slice = slice(p);
 		time_slice_expired(p, rq);
+		p->totalrun = 0;
 		goto out_unlock;
 	}
 	/*

