From: "Devon H. O'Dell" <devon.odell@gmail.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] Re: [sources] 20070413: /rc/bin/cpurc.local
Date: Sun, 15 Apr 2007 16:34:05 -0400 [thread overview]
Message-ID: <9ab217670704151334k121fbbffp426cd8c379848bad@mail.gmail.com> (raw)
In-Reply-To: <20070415175854.B53311E8C26@holo.morphisms.net>
2007/4/15, Russ Cox <rsc@swtch.com>:
> /* cooperative scheduling until the clock ticks */
> if((p=m->readied) && p->mach==0 && p->state==Ready
> && runq[Nrq-1].head == nil && runq[Nrq-2].head == nil){
>
> The tests are:
>
> p=m->readied
> some process p was last readied on this cpu (Mach)
>
> p->mach == 0
> p is not running on any cpu right now
Not to be overly annoying, but _is_ it possible that between the
assignment and that test, p->mach is set, indicating another CPU took
over? It just doesn't seem like m->readied is locked, at all; it seems
like another CPU could pick it up in the middle.
> p->state == Ready
> p is still Ready (waiting to run)
>
> runq[Nrq-1].head == nil && runq[Nrq-2].head == nil
> there are no real-time processes waiting to run
>
> If all those succeed, then the code tries to choose
> p to run next. But it might not -- the next thing that
> happens is
>
> p = dequeueproc(rq, p);
>
> which can return nil if p has already been grabbed
> or even if there is contention for the runq lock.
> All the accesses in the if condition are just fine --
> they happen without a lock but dequeueproc double-checks
> that p is okay to schedule.
>
> If dequeueproc returns nil, then runproc won't pick
> the readied p after all -- it will fall into the regular
> scheduling loop to find a process.
>
> Russ
Thanks for the low-level explanation. It does really help my understanding.
--dho
next prev parent reply other threads:[~2007-04-15 20:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <f93786a38200d44b7406b3181b4e2c20@cat-v.org>
2007-04-15 8:06 ` Uriel
2007-04-15 17:00 ` Uriel
2007-04-15 17:26 ` Devon H. O'Dell
2007-04-15 17:35 ` erik quanstrom
2007-04-15 17:37 ` Devon H. O'Dell
2007-04-15 17:38 ` Russ Cox
2007-04-15 17:43 ` Uriel
2007-04-15 20:31 ` Devon H. O'Dell
2007-04-15 17:43 ` Devon H. O'Dell
2007-04-15 17:59 ` Russ Cox
2007-04-15 20:34 ` Devon H. O'Dell [this message]
2007-04-17 5:21 ` Russ Cox
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=9ab217670704151334k121fbbffp426cd8c379848bad@mail.gmail.com \
--to=devon.odell@gmail.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).