Michael, I beleive -20 is the highest priority process while 19 is the lowest priority process i.e, priority rule is "smaller the number higher the priority" i.e, in my case -20 ==> -20 + 20 = 0 -19 ==> -19 + 20 = 1 ..... .. 18 ==> 18 + 20 = 38 19 ==> 19 + 20 = 39 We "prevent" the priority rule in this mapping. In the current code... -20 ===> 20 - (-20) = 40 -19 ===> 20 - (-19) = 39 -18 ===> 20 - (-18) = 38 .... 19 ===> 20 - 19 = 1 This mapping violates the "priority rule". While I correct my earlier statement from niceval = 20 + p->nice to niceval = 21 + p->niceval (Just to make sure it indeed ranges from 1-40 )I still beleive it should be "+" instead of "-". --Asok --- Michael Covi <thebaron22@optushome.com.au> wrote: > This seems to be correct to me. Remember 20 - ( -20) > = 40 > > and it says that it returns 40..1 instead of -20..19 > > 40...20...1 > -20...0..19 > > etc > > On Sun, 9 Dec 2001, Asok Tiyyagura wrote: > > > Hi guys, > > > > I am a newbie. Please correct me if I am wrong. > The > > function sys_getpriority() returns max priority of > a > > group of processes. But the code below seems to > have a > > bug. I believe the statement > > > > niceval = 20 - p->nice; > > > > should have been > > > > niceval = 20 + p->nice; > > > > Thanks in advance, > > Asok > > > > /* > > * Ugh. To avoid negative return values, > "getpriority > > ()" will > > * 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) > > { > > struct task_struct *p; > > long retval = -ESRCH; > > > > if (which > 2 || which < 0) > > return -EINVAL; > > > > read_lock(&tasklist_lock); > > for_each_task (p) { > > long niceval; > > if (!proc_sel(p, which, who)) > > continue; > > niceval = 20 - p->nice; > > if (niceval > retval) > > retval = niceval; > > } > > read_unlock(&tasklist_lock); > > > > return retval; > > } > > > > > > __________________________________________________ > > Do You Yahoo!? > > Send your FREE holiday greetings online! > > http://greetings.yahoo.com > > -- > > Kernelnewbies: Help each other learn about the > Linux kernel. > > Archive: > http://mail.nl.linux.org/kernelnewbies/ > > IRC Channel: irc.openprojects.net / > #kernelnewbies > > Web Page: http://www.kernelnewbies.org/ > > > __________________________________________________ Do You Yahoo!? Check out Yahoo! Shopping and Yahoo! Auctions for all of your unique holiday gifts! Buy at http://shopping.yahoo.com or bid at http://auctions.yahoo.com -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ IRC Channel: irc.openprojects.net / #kernelnewbies Web Page: http://www.kernelnewbies.org/