--- ./kernel/sys.c.orig Wed Nov 27 14:35:50 2002 +++ ./kernel/sys.c Thu Dec 5 19:28:51 2002 @@ -240,10 +240,10 @@ /* normalize: avoid signed division (rounding problems) */ error = -ESRCH; - if (niceval < -20) - niceval = -20; - if (niceval > 19) - niceval = 19; + if (niceval < PRIO_MIN) + niceval = PRIO_MIN; + if (niceval > PRIO_MAX - 1) + niceval = PRIO_MAX - 1; read_lock(&tasklist_lock); switch (which) { @@ -305,7 +305,7 @@ who = current->pid; p = find_task_by_pid(who); if (p) { - niceval = 20 - task_nice(p); + niceval = PRIO_MAX - task_nice(p); if (niceval > retval) retval = niceval; } @@ -314,7 +314,7 @@ if (!who) who = current->pgrp; for_each_task_pid(who, PIDTYPE_PGID, p, l, pid) { - niceval = 20 - task_nice(p); + niceval = PRIO_MAX - task_nice(p); if (niceval > retval) retval = niceval; } @@ -330,7 +330,7 @@ do_each_thread(g, p) if (p->uid == who) { - niceval = 20 - task_nice(p); + niceval = PRIO_MAX - task_nice(p); if (niceval > retval) retval = niceval; } --- ./kernel/sched.c.orig Wed Nov 27 14:36:17 2002 +++ ./kernel/sched.c Thu Dec 5 19:28:51 2002 @@ -45,7 +45,7 @@ /* * 'User priority' is the nice value converted to something we * can work with better when scaling various scheduler parameters, - * it's a [ 0 ... 39 ] range. + * it's in [ 0 ... 39 ] range. */ #define USER_PRIO(p) ((p)-MAX_RT_PRIO) #define TASK_USER_PRIO(p) USER_PRIO((p)->static_prio) @@ -1284,7 +1284,7 @@ prio_array_t *array; runqueue_t *rq; - if (TASK_NICE(p) == nice || nice < -20 || nice > 19) + if (TASK_NICE(p) == nice || nice < PRIO_MIN || nice > PRIO_MAX - 1) return; /* * We have to be careful, if called from sys_setpriority(), @@ -1336,17 +1336,18 @@ if (increment < 0) { if (!capable(CAP_SYS_NICE)) return -EPERM; - if (increment < -40) - increment = -40; + + if (increment < PRIO_MIN - PRIO_MAX) + increment = PRIO_MIN - PRIO_MAX; } - if (increment > 40) - increment = 40; + if (increment > (PRIO_MAX - PRIO_MIN)) + increment = PRIO_MAX - PRIO_MIN; nice = PRIO_TO_NICE(current->static_prio) + increment; - if (nice < -20) - nice = -20; - if (nice > 19) - nice = 19; + if (nice < PRIO_MIN) + nice = PRIO_MIN; + if (nice > PRIO_MAX - 1) + nice = PRIO_MAX - 1; if ((retval = security_task_setnice(current, nice))) return retval;