9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Philippe Anel <xigh@bouyapop.org>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] run queues
Date: Thu,  3 Jun 2010 08:43:47 +0200	[thread overview]
Message-ID: <4C074F23.1060104@bouyapop.org> (raw)


Hi 9fans,

While reading src/9/port/proc.c:^runproc, I realized that the
following code is called without any lock. I would expect one in order
to walk through the each rq lists, as it is called with interrupt
enabled.

I think this would not crash the system because procs are not
dynamically allocated or freed.

I also know that locking can be a problem regarding performance.

        for(rq = &runq[Nrq-1]; rq >= runq; rq--){
            for(p = rq->head; p; p = p->rnext){
                if(p->mp == nil || p->mp == MACHP(m->machno)
                || (!p->wired && i > 0))
                    goto found;
            }
        }

What do you think ?

Phil;

Ps: It seems runqs were designed to be individually locked. Is there
any info about the reason why all the runq are locked at once using :

    lock(runq);
    // ...
    unlock(runq);

where we could expect (with some other changes of course) :

    lock(rq);
    // ...
    unlock(rq);

?



             reply	other threads:[~2010-06-03  6:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-03  6:43 Philippe Anel [this message]
2010-06-03  7:01 ` Sape Mullender
2010-06-03  7:15   ` Philippe Anel
2010-06-03  8:12     ` Sape Mullender

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=4C074F23.1060104@bouyapop.org \
    --to=xigh@bouyapop.org \
    --cc=9fans@9fans.net \
    /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).