Index: linux-2.6.7-ck3-s7.8/include/linux/sched.h =================================================================== --- linux-2.6.7-ck3-s7.8.orig/include/linux/sched.h 2004-06-30 21:33:13.046545417 +1000 +++ linux-2.6.7-ck3-s7.8/include/linux/sched.h 2004-06-30 21:41:20.018582695 +1000 @@ -174,7 +174,7 @@ void io_schedule(void); long io_schedule_timeout(long timeout); -extern int interactive, compute; +extern int sched_interactive, sched_compute; extern void cpu_init (void); extern void trap_init(void); @@ -559,6 +559,8 @@ #define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */ #define PF_SYNCWRITE 0x00200000 /* I am doing a sync write */ #define PF_FORKED 0x00400000 /* I have just forked */ +#define PF_YIELDED 0x00800000 /* I have just yielded */ +#define PF_UISLEEP 0x01000000 /* Uninterruptible sleep */ #ifdef CONFIG_SMP #define SCHED_LOAD_SCALE 128UL /* increase resolution of load */ Index: linux-2.6.7-ck3-s7.8/kernel/sched.c =================================================================== --- linux-2.6.7-ck3-s7.8.orig/kernel/sched.c 2004-06-30 21:33:13.026548494 +1000 +++ linux-2.6.7-ck3-s7.8/kernel/sched.c 2004-06-30 21:33:32.545545471 +1000 @@ -68,14 +68,14 @@ */ #define NS_TO_JIFFIES(TIME) ((TIME) / (1000000000 / HZ)) -int compute = 0; +int sched_compute = 0; /* *This is the time all tasks within the same priority round robin. *compute setting is reserved for dedicated computational scheduling *and has ten times larger intervals. */ #define _RR_INTERVAL ((10 * HZ / 1000) ? : 1) -#define RR_INTERVAL (_RR_INTERVAL * (1 + 9 * compute)) +#define RR_INTERVAL() (_RR_INTERVAL * (1 + 9 * sched_compute)) #define task_hot(p, now, sd) ((now) - (p)->timestamp < (sd)->cache_hot_time) @@ -190,7 +190,7 @@ static int rr_interval(task_t * p) { - int rr_interval = RR_INTERVAL; + int rr_interval = RR_INTERVAL(); if (batch_task(p)) rr_interval *= 10; else if (iso_task(p)) @@ -204,7 +204,7 @@ { if (p->prio >= rq->curr->prio) return 0; - if (!compute || rq->cache_ticks >= cache_decay_ticks || + if (!sched_compute || rq->cache_ticks >= cache_decay_ticks || rt_task(p) || !p->mm || rq->curr == rq->idle || (batch_task(rq->curr))) return 1; @@ -300,18 +300,18 @@ */ static unsigned int slice(task_t *p) { - unsigned int slice = RR_INTERVAL; + unsigned int slice = RR_INTERVAL(); if (!rt_task(p)) - slice += burst(p) * RR_INTERVAL; + slice += burst(p) * RR_INTERVAL(); if (batch_task(p)) slice *= 10; return slice; } /* - * interactive - sysctl which allows interactive tasks to have bursts + * sched_interactive - sysctl which allows interactive tasks to have bursts */ -int interactive = 1; +int sched_interactive = 1; /* * effective_prio - dynamic priority dependent on burst. @@ -336,7 +336,7 @@ if (p->burst > best_burst) p->burst = best_burst; first_slice = rr; - if (interactive && !compute) + if (sched_interactive && !sched_compute) first_slice *= (p->burst + 1); prio = MAX_PRIO - 2 - best_burst; @@ -358,7 +358,8 @@ unsigned long sleep_time = now - p->timestamp; unsigned long ns_totalrun = p->totalrun + p->runtime; unsigned long total_run = NS_TO_JIFFIES(ns_totalrun); - if (p->flags & PF_FORKED || (!(NS_TO_JIFFIES(p->runtime)) && + if (p->flags & PF_FORKED || ((!(NS_TO_JIFFIES(p->runtime)) || + !sched_interactive || sched_compute) && NS_TO_JIFFIES(p->runtime + sleep_time) < rr_interval(p))) { p->flags &= ~PF_FORKED; if (p->slice - total_run < 1) { @@ -369,7 +370,8 @@ p->slice -= total_run; } } else { - inc_burst(p); + if (!(p->flags & PF_UISLEEP)) + inc_burst(p); p->runtime = 0; p->totalrun = 0; } @@ -391,6 +393,7 @@ #endif p->slice = slice(p); recalc_task_prio(p, now); + p->flags &= ~PF_UISLEEP; p->prio = effective_prio(p); p->time_slice = rr_interval(p); if (batch_task(p)) @@ -405,8 +408,10 @@ static void deactivate_task(struct task_struct *p, runqueue_t *rq) { rq->nr_running--; - if (p->state == TASK_UNINTERRUPTIBLE) + if (p->state == TASK_UNINTERRUPTIBLE) { + p->flags |= PF_UISLEEP; rq->nr_uninterruptible++; + } dequeue_task(p, rq); } @@ -1973,6 +1978,12 @@ clear_tsk_need_resched(prev); RCU_qsctr(task_cpu(prev))++; prev->timestamp = now; + if (next->flags & PF_YIELDED) { + next->flags &= ~PF_YIELDED; + dequeue_task(next, rq); + next->prio = effective_prio(next); + enqueue_task_head(next, rq); + } if (likely(prev != next)) { rq->preempted = 0; @@ -2675,9 +2686,11 @@ dequeue_task(current, rq); current->slice = slice(current); - current->time_slice = RR_INTERVAL; - if (!rt_task(current) && !batch_task(current)) + current->time_slice = rr_interval(current); + if (!rt_task(current) && !batch_task(current)) { + current->flags |= PF_YIELDED; current->prio = MAX_PRIO - 2; + } current->burst = 0; enqueue_task(current, rq); Index: linux-2.6.7-ck3-s7.8/kernel/sysctl.c =================================================================== --- linux-2.6.7-ck3-s7.8.orig/kernel/sysctl.c 2004-06-30 21:33:10.663911988 +1000 +++ linux-2.6.7-ck3-s7.8/kernel/sysctl.c 2004-06-30 21:33:32.547545163 +1000 @@ -639,7 +639,7 @@ { .ctl_name = KERN_INTERACTIVE, .procname = "interactive", - .data = &interactive, + .data = &sched_interactive, .maxlen = sizeof (int), .mode = 0644, .proc_handler = &proc_dointvec, @@ -647,7 +647,7 @@ { .ctl_name = KERN_COMPUTE, .procname = "compute", - .data = &compute, + .data = &sched_compute, .maxlen = sizeof (int), .mode = 0644, .proc_handler = &proc_dointvec,