This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix nice


Thorsten Kukuk <kukuk@suse.de> writes:

> On Thu, Feb 28, Jakub Jelinek wrote:
>
>> Hi!
>> 
>> 2001-06-04 patch for nice apparently changed nothing at all on linux, since
>> sysdeps/unix/nice.c which was patched is overridden in
>> sysdeps/unix/sysv/syscalls.list (nice), thus nice still returns 0 on
>> success, not the actual new priority.
>> Fix below. I have briefly tested that it works as expected on ia32 linux.
>
> I found another problem: according to 1003.1-2001:
>
> Requests for values above or below 2*{NZERO}-1 shall result in the 
> nice value being set to the corresponding limit.
>
> In the moment we return "prio + incr" and fail the test. Should we
> change this to a "return getpriority (PRIO_PROCESS, 0);" or should
> we recalculate the return value with help of the NZERO definition?
>
> A simple patch which works for me:
>
> 2002-03-02  Thorsten Kukuk  <kukuk@suse.de>
>
>         * sysdeps/unix/nice.c: Use getpriority() for the return value
>  
> --- sysdeps/unix/nice.c
> +++ sysdeps/unix/nice.c 2002/03/02 09:40:14
> @@ -43,7 +43,7 @@
>
>    result = setpriority (PRIO_PROCESS, 0, prio + incr);
>    if (result != -1)
> -    return prio + incr;
> +    return getpriority (PRIO_PROCESS, 0);
>    else
>      return -1;

Just for reference, the current implementation behaves this way:
nice(0)=0       getpriority()=0
nice(-100)=-100 getpriority()=-20
nice(-80)=-100  getpriority()=-20
nice(-60)=-80   getpriority()=-20
nice(-40)=-60   getpriority()=-20
nice(-20)=-40   getpriority()=-20
nice(0)=-20     getpriority()=-20
nice(20)=0      getpriority()=0
nice(40)=40     getpriority()=19
nice(60)=79     getpriority()=19
nice(80)=99     getpriority()=19
nice(100)=119   getpriority()=19

A return value of 119 is defintely wrong,
Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]