9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox <rsc@swtch.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Cc: erik quanstrom <quanstro@quanstro.net>
Subject: Re: [9fans] sleep/wakeup bug?
Date: Fri, 25 Feb 2011 00:47:56 -0500	[thread overview]
Message-ID: <AANLkTinuyGgidt_Lz9rQ8VyVtTVdnU2TABmbZG7NWt8g@mail.gmail.com> (raw)
In-Reply-To: <11da45046fa8267e7445128ed00724cd@ladd.quanstro.net>

>> 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.

> 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).

> 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.

russ


  reply	other threads:[~2011-02-25  5:47 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 [this message]
2011-02-25  5:53   ` erik quanstrom
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=AANLkTinuyGgidt_Lz9rQ8VyVtTVdnU2TABmbZG7NWt8g@mail.gmail.com \
    --to=rsc@swtch.com \
    --cc=9fans@9fans.net \
    --cc=quanstro@quanstro.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).