[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
sys_getpriority()
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/