From: Venkatesh Srinivas <me@acm.jhu.edu>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] sleep/wakeup bug?
Date: Fri, 25 Feb 2011 11:09:03 -0500 [thread overview]
Message-ID: <AANLkTikNzAvDD_i-BZR7fNay_tXm_owJf-ag1S0RbuM3@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=FabYqOd3ozUEXi9_Ua8S5DujfUjhzCYxPF2TA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]
On Fri, Feb 25, 2011 at 1:51 AM, Russ Cox <rsc@swtch.com> wrote:
> > your layout in your first email (i think) assumes that wakeup
> > can be called twice.
>
> it doesn't. the scenario in my first email has exactly one
> sleep and one wakeup.
>
> the canonical problem you have to avoid when implementing
> sleep and wakeup is that the wakeup might happen before
> the sleep has gotten around to sleeping.
>
There is a pattern in DragonFly BSD for use with tsleep (tsleep is
evolutionarily related to p9's sleep, though the descent is tortuous),
tsleep_interlock.
tsleep_interlock(WAITCHAN);
/* Kick off some operation or release some higher level lock or w/e */
tsleep(WAITCHAN, ...);
tsleep_interlock queues a process but does not actually go to sleep. If a
wakeup happens after the tsleep_interlock but before tsleep has fully slept,
the process does not sleep in tsleep().
I do not know if a similar design would be feasible given Plan 9's
sleep/wakeup; at first glance, it looks to be so - sleep_interlock would
look similar to sleep's front-end, but it would not 'gotolabel(&m->sched)'.
-- vs
[-- Attachment #2: Type: text/html, Size: 1480 bytes --]
next prev parent reply other threads:[~2011-02-25 16:09 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
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 [this message]
-- 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=AANLkTikNzAvDD_i-BZR7fNay_tXm_owJf-ag1S0RbuM3@mail.gmail.com \
--to=me@acm.jhu.edu \
--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).