diff -urNp x-ref/kernel/context.c x/kernel/context.c --- x-ref/kernel/context.c 2002-12-25 19:29:09.000000000 +0100 +++ x/kernel/context.c 2002-12-25 19:29:58.000000000 +0100 @@ -81,7 +81,7 @@ static int context_thread(void *startup) * This also means keventd must not be abused for not must-do tasks. */ keventd_task->policy = SCHED_RR; - keventd_task->rt_priority = MAX_USER_RT_PRIO; + keventd_task->rt_priority = MAX_RT_PRIO-1; spin_lock_irq(&curtask->sigmask_lock); siginitsetinv(&curtask->blocked, sigmask(SIGCHLD)); diff -urNp x-ref/kernel/sched.c x/kernel/sched.c --- x-ref/kernel/sched.c 2002-12-25 19:29:10.000000000 +0100 +++ x/kernel/sched.c 2002-12-25 19:29:58.000000000 +0100 @@ -174,6 +174,13 @@ static inline int effective_prio(task_t { int bonus, prio; + if (rt_task(p)) { + prio = MAX_RT_PRIO-1 - p->rt_priority; + BUG_ON(prio < 0); + BUG_ON(prio >= MAX_RT_PRIO); + return prio; + } + /* * Here we scale the actual sleep average [0 .... MAX_SLEEP_AVG] * into the -5 ... 0 ... +5 bonus/penalty range. @@ -202,18 +209,20 @@ static inline void __activate_task(task_ unsigned long sleep_time = jiffies - p->sleep_timestamp; prio_array_t *array = rq->active; - if (!parent && !rt_task(p) && sleep_time) { - /* - * This code gives a bonus to interactive tasks. We update - * an 'average sleep time' value here, based on - * sleep_timestamp. The more time a task spends sleeping, - * the higher the average gets - and the higher the priority - * boost gets as well. - */ - p->sleep_timestamp = jiffies; - p->sleep_avg += sleep_time; - if (p->sleep_avg > MAX_SLEEP_AVG) - p->sleep_avg = MAX_SLEEP_AVG; + if (!parent) { + if (sleep_time && !rt_task(p)) { + /* + * This code gives a bonus to interactive tasks. We update + * an 'average sleep time' value here, based on + * sleep_timestamp. The more time a task spends sleeping, + * the higher the average gets - and the higher the priority + * boost gets as well. + */ + p->sleep_timestamp = jiffies; + p->sleep_avg += sleep_time; + if (p->sleep_avg > MAX_SLEEP_AVG) + p->sleep_avg = MAX_SLEEP_AVG; + } p->prio = effective_prio(p); } __enqueue_task(p, array, parent); @@ -408,7 +417,6 @@ void wake_up_forked_process(task_t * p) * it's a child of the first idle task (during boot * only). */ - p->prio = effective_prio(p); parent = NULL; } @@ -819,6 +827,7 @@ void scheduler_tick(int user_tick, int s /* put it at the end of the queue: */ dequeue_task(p, rq->active); + p->prio = effective_prio(p); enqueue_task(p, rq->active); } goto out; @@ -1188,7 +1197,7 @@ asmlinkage long sys_nice(int increment) */ int task_prio(task_t *p) { - return p->prio - MAX_USER_RT_PRIO; + return p->prio - MAX_RT_PRIO; } int task_nice(task_t *p) @@ -1269,7 +1278,7 @@ static int setscheduler(pid_t pid, int p p->policy = policy; p->rt_priority = lp.sched_priority; if (policy != SCHED_OTHER) - p->prio = MAX_USER_RT_PRIO-1 - p->rt_priority; + p->prio = MAX_RT_PRIO-1 - p->rt_priority; else p->prio = p->static_prio; if (array) @@ -1453,7 +1462,11 @@ asmlinkage long sys_sched_yield(void) array = current->array; if (unlikely(rt_task(current))) { list_del(¤t->run_list); + if (list_empty(array->queue + current->prio)) + __clear_bit(current->prio, array->bitmap); + current->prio = MAX_RT_PRIO-1; list_add_tail(¤t->run_list, array->queue + current->prio); + __set_bit(current->prio, array->bitmap); goto out_unlock; }