Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!husc6!bbn!oberon!cit-vax!mangler From: mangler@cit-vax.Caltech.Edu (Don Speck) Newsgroups: comp.unix.questions Subject: Re: "Deep Background" applications Keywords: BSD nice loadave priority scheduler Message-ID: <7230@cit-vax.Caltech.Edu> Date: 10 Jul 88 03:25:43 GMT References: <649@necis.UUCP> <29500025@urbsdc> <11019@cgl.ucsf.EDU> <1303@maccs.McMaster.CA> Organization: California Institute of Technology Lines: 36 A niceness of 20 is neither necessary nor sufficient by itself. The low-level scheduler gives the CPU to the ready-to-run process having the smallest value of p_pri. Except during system calls, this is the same as p_usrpri. For a "Deep Background" process, you want the largest legal value of p_usrpri, namely 127, even in the absence of CPU ticks. If you merely don't want to compete with processes at nice 0, then 100 is enough. N.B. "ps" and "top" display PRI = p_pri - PZERO (PZERO is 25). In 4.2 BSD, p_usrpri works out to (in a *very* roundabout fashion via a time recurrence in p_cpu): p_usrpri = PUSER + (nrscale*avenrun[0] + 9)*(p_nice - NZERO)/4 plus CPU ticks. PUSER is 50 and nrscale is 2. Notice that the effect of niceness is multiplied by the load average. Solving, we get: loadavg for p_usrpri of niceness --127-- --100-- 28 1.0 20 3.2 0.5 10 10.9 5.5 4 34 20.5 Although 4.2 BSD doesn't allow a niceness of 28, it's easy enough to modify donice(). Convex's version allows niceness up to 64. The fact that any positive niceness can become "deep background" at a sufficient load average makes it risky to "nice" anything that has timeouts or holds some scarce resource. System V doesn't seem to have a "deep background". Don Speck speck@vlsi.caltech.edu {amdahl,ames!elroy}!cit-vax!speck