9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@labs.coraid.com>
To: 9fans@9fans.net
Subject: Re: [9fans] sleep/wakeup bug?
Date: Fri, 25 Feb 2011 00:53:13 -0500	[thread overview]
Message-ID: <24bb48f61c5eab87a133b82a9ef32474@coraid.com> (raw)
In-Reply-To: <AANLkTinuyGgidt_Lz9rQ8VyVtTVdnU2TABmbZG7NWt8g@mail.gmail.com>

> >> assuming a tight 1:1 coupling between sleep and
> >> wakeup is a recipe for trouble.  even if your change
> >> fixes one possible race (i didn't bother to see what changed),
> >> you still have to deal with
> >
> > the point of sleep/rendezvous is tight coupling, no?
>
> no, it's not 1:1.

i don't yet see why this assumption isn't a good one to have.
what is the argument against tightening it up?  i don't see it yet.

> > the change was to move the ready() to after the rendezvous
> > lock was dropped.  therefore the sleeper knows the rendezvous
> > is not locked by the event that woke him.  if one can assert
> > that each sleep has exactly one wakeup (as is often the case
> > for rpc-style programming), then that is enough to know
> > the rendezvous can be retired.
>
> that's only true if the sleep sleeps.
> if sleep checks f(arg) and finds it to be true, then it will not
> sleep, and the subsequent wakeup will happen after sleep
> returns (and be a no-op, unless the memory has been freed).

and that case is fine, too.  either way, we're "done".

> > if not a tight coupling, what kind of coupling would you
> > think is appropriate?  when would you think it would be
> > fair to recycle the rendezvous?  10s?  :-)  what idiom do
> > you think would be appropriate for such a case?
>
> it is appropriate to reuse the memory when you know that
> no cpu is still referring to it.  you can deal with the main procs.
> interrupt handlers are the wildcard.  put an ilock around the table
> where the pointer to it is kept, and only use the memory
> (from an interrupt handler) while inside the ilock.

since i know i'm done when the wakeup happens, the wakeup
itself is causing the trouble.  it starts the sleeper before releasing
the rendezvous lock.  so your solution would have me have an ilock
(with no interrupt in sight!) to protect rendezvous from itself?

why can't rendezvous carry its own water?

- erik



  reply	other threads:[~2011-02-25  5:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-25  5:26 erik quanstrom
2011-02-25  5:47 ` Russ Cox
2011-02-25  5:53   ` erik quanstrom [this message]
2011-02-25  6:01     ` Russ Cox
2011-02-25  6:12       ` erik quanstrom
     [not found]       ` <2808a9fa079bea86380a8d52be67b980@coraid.com>
     [not found]         ` <AANLkTi=4_=++Tm2a9Jq9jSzqUSexkW-ZjM-38oD_bS1y@mail.gmail.com>
     [not found]           ` <40925e8f64489665bd5bd6ca743400ea@coraid.com>
2011-02-25  6:51             ` Russ Cox
2011-02-25  7:13               ` erik quanstrom
2011-02-25 14:44                 ` Russ Cox
2011-02-25  8:37               ` Sape Mullender
2011-02-25  9:18                 ` Bakul Shah
2011-02-25 14:57               ` Charles Forsyth
2011-02-25 16:09               ` Venkatesh Srinivas
  -- strict thread matches above, loose matches on Subject: below --
2011-02-24 22:01 erik quanstrom
2011-02-25  4:46 ` Russ Cox
2011-02-25  9:46 ` Richard Miller

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=24bb48f61c5eab87a133b82a9ef32474@coraid.com \
    --to=quanstro@labs.coraid.com \
    --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).