--- linux-2.6.0-test1-mm1/kernel/sched.c 2003-07-17 19:59:16.000000000 +1000 +++ linux-2.6.0-testck1/kernel/sched.c 2003-07-19 01:56:41.000000000 +1000 @@ -76,7 +76,6 @@ #define MIN_SLEEP_AVG (HZ) #define MAX_SLEEP_AVG (10*HZ) #define STARVATION_LIMIT (10*HZ) -#define SLEEP_BUFFER (HZ/100) #define NODE_THRESHOLD 125 #define MAX_BONUS (MAX_USER_PRIO * PRIO_BONUS_RATIO / 100) @@ -391,11 +390,11 @@ static inline void activate_task(task_t if (sleep_time > 0) { /* - * Tasks that sleep a long time are categorised as idle and + * User tasks that sleep a long time are categorised as idle and * will get just under interactive status with a small runtime * to allow them to become interactive or non-interactive rapidly */ - if (sleep_time > MIN_SLEEP_AVG){ + if (sleep_time > MIN_SLEEP_AVG && p->mm){ p->avg_start = jiffies - MIN_SLEEP_AVG; p->sleep_avg = MIN_SLEEP_AVG * (MAX_BONUS - INTERACTIVE_DELTA - 2) / MAX_BONUS; @@ -421,13 +420,8 @@ static inline void activate_task(task_t */ p->sleep_avg = (p->sleep_avg * MAX_BONUS / runtime + 1) * runtime / MAX_BONUS; - /* - * Keep a small buffer of SLEEP_BUFFER sleep_avg to - * prevent fully interactive tasks from becoming - * lower priority with small bursts of cpu usage. - */ - if (p->sleep_avg > (MAX_SLEEP_AVG + SLEEP_BUFFER)) - p->sleep_avg = MAX_SLEEP_AVG + SLEEP_BUFFER; + if (p->sleep_avg > MAX_SLEEP_AVG) + p->sleep_avg = MAX_SLEEP_AVG; } if (unlikely(p->avg_start > jiffies)){ @@ -1310,10 +1304,12 @@ void scheduler_tick(int user_ticks, int enqueue_task(p, rq->expired); } else enqueue_task(p, rq->active); - } else if (p->prio < effective_prio(p)){ + } else if (p->mm && !((task_timeslice(p) - p->time_slice) % + (MIN_TIMESLICE * (MAX_BONUS + 1 - p->sleep_avg * MAX_BONUS / MAX_SLEEP_AVG)))){ /* - * Tasks that have lowered their priority are put to the end - * of the active array with their remaining timeslice + * Running user tasks get requeued with their remaining timeslice + * after a period proportional to how cpu intensive they are to + * minimise the duration one interactive task can starve another */ dequeue_task(p, rq->active); set_tsk_need_resched(p);