9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Bakul Shah <bakul@bitblocks.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] devmnt crash, fix.
Date: Thu, 23 Aug 2012 10:53:25 -0700	[thread overview]
Message-ID: <20120823175325.EEF27B85B@mail.bitblocks.com> (raw)
In-Reply-To: Your message of "Thu, 23 Aug 2012 12:47:10 EDT." <CAOw7k5ii5PoYZnEbDeUuhR9GsgEEGt7i+XTQm7FR9+r=ENg=xw@mail.gmail.com>

On Thu, 23 Aug 2012 12:47:10 EDT Charles Forsyth <charles.forsyth@gmail.com>  wrote:
> No. It's not true that all sleeps might return spuriously (it might have
> been true in Unix, I can't remember).
> It's not true in Plan 9.

It is not that sleep might return spuriously (that is, the
wakeup condition is still false) but that it may have *become*
false once again due to an action by another process before
the sleeper has had a chance to run.  To handle this one would
use a pattern like this

	while (!wakeup_condition(&foo))
		sleep(&foo);

I haven't looked at this in ages but this used to be the case
in unix.  So here awakening everyone *spuriously* is /safe/
(but not efficient).

doc/sleep.ps says
    We assume that a particular call to sleep corresponds to a
    particular call to wakeup, that is, at most one process is
    asleep waiting for a particular event.

But it is not clear to me that another process can't get in to
change the condition between the time wakeup() is called and
the sleeper actually runs -- the above condition is not
violated as the new process won't be sleeping. But if yet
another process tries to access the same condition, it will be
blocked on getting the rendezvous structure lock?



  parent reply	other threads:[~2012-08-23 17:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-22 18:53 erik quanstrom
2012-08-22 19:09 ` cinap_lenrek
2012-08-22 19:12 ` cinap_lenrek
2012-08-22 19:53 ` cinap_lenrek
2012-08-22 22:26   ` erik quanstrom
2012-08-22 23:30 ` cinap_lenrek
2012-08-23  1:53   ` erik quanstrom
2012-08-23  9:47     ` cinap_lenrek
2012-08-23 13:27       ` erik quanstrom
2012-08-23 15:02         ` cinap_lenrek
2012-08-23 15:39         ` Bakul Shah
2012-08-23 15:48           ` erik quanstrom
2012-08-23 15:53           ` cinap_lenrek
2012-08-23 16:06             ` erik quanstrom
2012-08-23 16:18               ` cinap_lenrek
2012-08-23 16:24                 ` erik quanstrom
2012-08-23 16:47                   ` Charles Forsyth
2012-08-23 17:01                     ` cinap_lenrek
2012-08-23 17:53                     ` Bakul Shah [this message]
2012-08-23 18:03                       ` erik quanstrom
     [not found]                   ` <CAOw7k5ii5PoYZnEbDeUuhR9GsgEEGt7i+XTQm7FR9+r=ENg=xw@mail.gmail.c>
2012-08-23 17:09                     ` erik quanstrom

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=20120823175325.EEF27B85B@mail.bitblocks.com \
    --to=bakul@bitblocks.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).