Re: sys_getpriority()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/
>

--
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/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux