patch-2.4.0-test5 linux/kernel/sys.c

Next file: linux/kernel/sysctl.c
Previous file: linux/kernel/sched.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test4/linux/kernel/sys.c linux/kernel/sys.c
@@ -234,8 +234,9 @@
 
 /*
  * Ugh. To avoid negative return values, "getpriority()" will
- * not return the normal nice-value, but a value that has been
- * offset by 20 (ie it returns 0..39 instead of -20..19)
+ * not return the normal nice-value, but a negated value that
+ * has been offset by 20 (ie it returns 40..1 instead of -20..19)
+ * to stay compatible.
  */
 asmlinkage long sys_getpriority(int which, int who)
 {
@@ -247,11 +248,11 @@
 
 	read_lock(&tasklist_lock);
 	for_each_task (p) {
-		unsigned niceval;
+		long niceval;
 		if (!proc_sel(p, which, who))
 			continue;
-		niceval = p->nice + 20;
-		if (niceval < (unsigned)retval)
+		niceval = 20 - p->nice;
+		if (niceval > retval)
 			retval = niceval;
 	}
 	read_unlock(&tasklist_lock);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)