Automatic re-nicing of processes under 4.2 bsd

Larry Allen lwa at mit-mrclean.ARPA
Sat Nov 17 10:10:31 AEST 1984


One of our users noticed that processes which accumulated a lot of CPU
time under 4.2 bsd (for example, a Emacs which had been running on the
same terminal for 3 days) would suddenly and seemingly arbitrarily get
reniced.  After a little bit of tracking, I found the following code in
/sys/sys/kern_clock.c/softclock():

		/*
		 * Check to see if process has accumulated
		 * more than 10 minutes of user time.  If so
		 * reduce priority to give others a chance.
		 */
		if (p->p_uid && p->p_nice == NZERO &&
		    u.u_ru.ru_utime.tv_sec > 10 * 60) {
			p->p_nice = NZERO+4;
			(void) setpri(p);
			p->p_pri = p->p_usrpri;
		}

What this does is to reduce the nice of any process
1) which is not be run by the superuser
2) whose nice is 0
3) which has accumulated more that 10 minutes of CPU time in its lifetime
The nice of such a process is arbitrarily set to 4.

This whole strategy seems totally bogus to me - it penalizes long-lived
programs even if they're not CPU bound.  Moreover, it seems unnecessary -
there is already code in /sys/sys/kern_synch.c/schedcpu() (called by
timeout once a second) to reduce the scheduling priority of CPU-bound
processes and increase the scheduling priority of I/O-bound processes.

Can this code be eliminated?  Would there be any unexpected side-effects
I haven't thought of?
					-Larry Allen



More information about the Comp.unix.wizards mailing list