9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: presotto@plan9.bell-labs.com
To: 9fans@cse.psu.edu
Subject: [9fans] priority bug
Date: Thu, 28 Feb 2002 11:12:17 -0500	[thread overview]
Message-ID: <1effb825dbe9487afe6eff8834c89c96@plan9.bell-labs.com> (raw)

There are two priority classes in Plan 9, one for
kproc's and processes loaded with the kernel, and 
one for everything else.  They intersect at one
priority level, the former having the edge.  Due
to priority inheritence across fork, on the terminals
all processes fall in the first class.  If you are
getting screwed by cpu hogs, you might want to add
this to after the arg processing in init.c:

	int fd;
	char ctl[128];

	snprint(ctl, sizeof(ctl), "#p/%d/ctl", getpid());
	fd = open(ctl, OWRITE);
	if(fd < 0)
		print("init: warning: can't open %s: %r\n", ctl);
	else
		if(write(fd, "pri 10", 6) != 6)
			print("init: warning: can't set priority: %r\n");
	close(fd);

It'll drop init and everything it starts to the
lower class.

Also, you can make the kernel much more aggressive at stepping
on cpu hogs with the following change to ready() in proc.c:

change

		if(p->state == Running){
			p->rt++;
			pri = ((p->art + (p->rt<<1))>>2)/Squantum;
		} else {
			p->art = (p->art + (p->rt<<1))>>2;
			p->rt = 0;
			pri = p->art/Squantum;
		}

to

		if(p->state == Running){
			p->rt++;
			pri = (p->art + p->rt)/2;
		} else {
			p->art = (p->art + p->rt + 2)/2;
			pri = (p->art + p->rt)/2;
			p->rt = 0;
		}

It basicly gets rid of the damping so that things run up 
and down priority levels pretty quickly.  It helped rsc
when running his mp3 encoder.

Tell me of any adverse affects.  I'll stick it in the
distribution if noone is screwed by it.


             reply	other threads:[~2002-02-28 16:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-28 16:12 presotto [this message]
2002-02-28 17:07 ` Scott Schwartz
2002-02-28 17:59 presotto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1effb825dbe9487afe6eff8834c89c96@plan9.bell-labs.com \
    --to=presotto@plan9.bell-labs.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).