Index: linux-2.6.10-ckdev/kernel/sched.c
===================================================================
--- linux-2.6.10-ckdev.orig/kernel/sched.c	2005-01-13 14:51:12.000000000 +1100
+++ linux-2.6.10-ckdev/kernel/sched.c	2005-01-13 16:02:00.296269832 +1100
@@ -629,26 +629,22 @@
 	if (used_slice < first_slice)
 		return prio;
 	prio += 1 + (used_slice - first_slice) / rr;
-	if (prio >= MAX_PRIO - 2) {
-		p->totalrun = 0;
+	if (prio >= MAX_PRIO - 2)
 		prio = MAX_PRIO - 2;
-	}
 	return prio;
 }
 
-static void continue_slice(task_t *p, unsigned int rr)
+static void continue_slice(task_t *p)
 {
 	unsigned long total_run = NS_TO_JIFFIES(p->totalrun);
-	if (total_run >= p->slice && p->prio >= MAX_PRIO - 2) {
+
+	if (total_run >= p->slice) {
 		p->totalrun = 0;
 		dec_burst(p);
 	} else {
 		unsigned int remainder;
-		if (likely(total_run < p->slice))
-			p->slice -= total_run;
-		else
-			p->slice = 1;
-		remainder = p->slice % rr;
+		p->slice -= total_run;
+		remainder = p->slice % rr_interval(p);
 		if (remainder)
 			p->time_slice = remainder;
 	}
@@ -662,40 +658,35 @@
 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);
 
-	if (NS_TO_JIFFIES(p->totalrun) >= (p->slice - rr) &&
-		p->prio >= MAX_PRIO - 2) {
+	p->totalrun += p->runtime;
+	if (NS_TO_JIFFIES(p->totalrun) >= p->slice - 1 &&
+		NS_TO_JIFFIES(sleep_time) < p->slice) {
 			p->flags &= ~PF_FORKED;
+			dec_burst(p);
 			goto new_slice;
 	}
-	p->totalrun += p->runtime;
 
 	if (p->flags & PF_FORKED) {
-		continue_slice(p, rr);
+		continue_slice(p);
 		p->flags &= ~PF_FORKED;
 		goto out;
 	}
 
 	if (sched_compute) {
-		continue_slice(p, rr);
+		continue_slice(p);
 		goto out;
 	}
 
-	if (sleep_time >= p->totalrun)
-		goto reset_slice;
-	p->totalrun -= sleep_time;
-
-	if (NS_TO_JIFFIES(p->runtime + sleep_time) < rr) {
-		continue_slice(p, rr);
-		goto out;
+	if (sleep_time >= p->totalrun) {
+		inc_burst(p);
+		goto new_slice;
 	}
+
+	p->totalrun -= sleep_time;
+	continue_slice(p);
+	goto out;
 new_slice:
-	if (NS_TO_JIFFIES(p->totalrun) > p->burst * rr)
-		dec_burst(p);
-	else if (!(p->flags & PF_UISLEEP || p->totalrun))
-		inc_burst(p);
-reset_slice:
 	p->totalrun = 0;
 out:
 	return;
