[comp.unix.questions] Nicer than nice!

ad@cat.UUCP (Axel Dunkel) (02/04/90)

Is there a possibility to change the priority of a process more than a
'nice -19' would do? I would like be able to start programs in background
that get cpu time only if there is nearly nothing 'better' to do, so that
they don't cosume cpu time while there are other processes (apart from
init etc. of course) running. (for UNIX Sys V, R3.2).

Thanx for answers!
Axel Dunkel (ad@cat.UUCP, ...!unido!cat!ad)

merlyn@iwarp.intel.com (Randal Schwartz) (02/05/90)

In article <9400@cat.UUCP>, ad@cat (Axel Dunkel) writes:
| Is there a possibility to change the priority of a process more than a
| 'nice -19' would do? I would like be able to start programs in background
| that get cpu time only if there is nearly nothing 'better' to do, so that
| they don't cosume cpu time while there are other processes (apart from
| init etc. of course) running. (for UNIX Sys V, R3.2).

Nice isn't really a "priority" (the manpage lies) -- just a "hint" to
the scheduler.  There isn't anything in off-the-shelf UNIX that tags
the process as "don't run this unless nobody else is doing much of
anything."

Just another UNIX hacker,
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/

hegde@umvlsi.ecs.umass.edu (Uday Hegde) (02/06/90)

In article <1990Feb5.052345.2120@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes:
>In article <9400@cat.UUCP>, ad@cat (Axel Dunkel) writes:
>> Is there a possibility to change the priority of a process more than a
>> 'nice -19' would do? I would like be able to start programs in background

>Nice isn't really a "priority" (the manpage lies) -- just a "hint" to
>the scheduler.  There isn't anything in off-the-shelf UNIX that tags
>the process as "don't run this unless nobody else is doing much of
>anything."
>

Nice value of 19 does achieve this. 19 is a special process "priority" and the
process with that nice value runs only when nothing else in the system 
wants to.
Correct me if I wrong.

-------------------------------------------------------------------------------
Uday Hegde.                          internet: hegde@cs.umass.edu         
UMass, Amherst.                                hegde@umvlsi.ecs.umass.edu
Phone: 545-3899                       bitnet:  hegde@umass.bitnet    
_______________________________________________________________________________

lamy@cs.utoronto.ca (Jean-Francois Lamy) (02/06/90)

someone wrote:
>> Is there a possibility to change the priority of a process more than a
>> 'nice -19' would do? I would like be able to start programs in background

to which Randal Schwartz replied:
>>the scheduler.  There isn't anything in off-the-shelf UNIX that tags the
>>process as "don't run this unless nobody else is doing much of anything."

and Uday Hegde confuses matters by saying:
>process with that nice value [-19] runs only when nothing else in the system 
>wants to.
>Correct me if I wrong.

Indeed.  The scheduler uses niceness as one of many factors in determining
priority.  In *practice*, several maximally niced jobs can still impact
significantly the system performance.  Recent SunOS releases seem especially
prone to this behaviour (I will dispense you from my pet theories on the topic
because I'd like to check them with the source first, should we *ever* receive
it).

Some Unix mutants like SGI's IRIX actually have a direct way to acheive what
the original poster wanted (an idle cycle soaker running at a priority far
below that assigned by normal scheduling).  This is one of the reasons SGIs
have been selling well in this neck of the woods (for the price, they make
excellent compute servers and we can accomodate both interactive symbolic
algebra and monster TeX jobs at the same time as neural network simulations
that run forever).

Jean-Francois Lamy               lamy@cs.utoronto.ca, uunet!cs.utoronto.ca!lamy
Department of Computer Science, University of Toronto, Canada M5S 1A4

hegde@umvlsi.ecs.umass.edu (Uday Hegde) (02/07/90)

In article <90Feb5.165122est.5069@neat.cs.toronto.edu> lamy@cs.utoronto.ca (Jean-Francois Lamy) writes:
>someone wrote:
>>> Is there a possibility to change the priority of a process more than a

>and Uday Hegde confuses matters by saying:
>>process with that nice value [-19] runs only when nothing else in the system 
>>wants to.
>>Correct me if I am wrong.
>
>Indeed.  The scheduler uses niceness as one of many factors in determining
>priority.  In *practice*, several maximally niced jobs can still impact

Sorry! I was quoting the man pages for "nice" and "renice(8)" on ULTRIX when I
posted on the net. The man pages clearly states that nice value 19 is 
different from the rest and is useful when you want to ensure that the process
runs when nothing else in the system wants to. However, having actually 
experimented with different nice values, it appears that the man pages are 
wrong. My apologies for "causing confusion". :)

______________________________________________________________________________
Uday Hegde.                          internet: hegde@cs.umass.edu         
UMass, Amherst.                                hegde@umvlsi.ecs.umass.edu
Phone: (413) 545-3899                 bitnet:  hegde@umass.bitnet    
_______________________________________________________________________________

jaap+@andrew.cmu.edu (Jaap Akkerhuis) (02/07/90)

Excerpts from netnews.comp.unix.questions: 5-Feb-90 Re: Nicer than nice!
Jean-Francois Lamy@cs.ut (1522)

> someone wrote:
> >> Is there a possibility to change the priority of a process more than a
> >> 'nice -19' would do? I would like be able to start programs in background

> to which Randal Schwartz replied:
> >>the scheduler.  There isn't anything in off-the-shelf UNIX that tags the
> >>process as "don't run this unless nobody else is doing much of anything."

> and Uday Hegde confuses matters by saying:
> >process with that nice value [-19] runs only when nothing else in the system 
> >wants to.
> >Correct me if I wrong.

> Indeed.  The scheduler uses niceness as one of many factors in determining
> priority.  In *practice*, several maximally niced jobs can still impact
> significantly the system performance.  Recent SunOS releases seem especially
> prone to this behaviour (I will dispense you from my pet theories on the topic
> because I'd like to check them with the source first, should we *ever* receive
> it).

UNIX Edition 7 had the same problem. If I remember correctly, it was
caused by the fact that the swapper swapped anything in which hadn't be
in for a while and then the scheduler deciced it was a real nice
process, so it was swapped out again before being run. So processes
which were supposed to soak up only idle time still had an impact on the
system.

	jaap

guy@auspex.auspex.com (Guy Harris) (02/07/90)

>Nice value of 19 does achieve this. 19 is a special process "priority" and the
>process with that nice value runs only when nothing else in the system 
>wants to.
>Correct me if I wrong.

OK: you're wrong.

There is nothing "magic" about 19, it's just the maximum allowed
"niceness" value on S5 systems (I think it's 20 in 4.xBSD, at least for
x >= 2); in some systems, at least, the priority of a process with a
niceness of 0 can rise above the priority of a process with a niceness
of 19 if the fraction of the CPU that the first priority has been
getting gets high enough.

(BTW, there isn't necessarily one and only one process on the system
with a niceness of 19.)