9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Richard Bilson" <rcbilson@gmail.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] OT: cannonical set of queue ops
Date: Wed,  6 Dec 2006 17:58:06 -0500	[thread overview]
Message-ID: <676c3c4f0612061458gd767117qb67b4bce8b027e43@mail.gmail.com> (raw)
In-Reply-To: <283f5df10612061436i5179e5f7mc7930ebf1f3ec280@mail.gmail.com>

On 12/6/06, LiteStar numnums <litestar@gmail.com> wrote:
> >For instance, if IsQueueEmpty returns "true", that answer isn't worth
> very much if, by
> > the time you act on that information, some other thread could have
> > added an item to the queue.
>
> Wouldn't it be natural for such a function to block the active thread
> until the desired
> result is achieved? Since this clean up thread wouldn't really need to
> be on a hard deadline, wouldn't WaitQueueEmpty make more sense then a
> IsQueueEmpty? The writer may be more difficult, but again, if the
> Queue is full, it must wait anyway, so blocking here wouldn't be too
> problematic, methinks.

You could do that as well, but that doesn't address the fundamental
problem that I was pointing out regarding IsQueueEmpty: once you wake
up you don't really know anything about the state of the queue, unless
you are sure that no other thread could be adding items. All you know
in general is that the queue was recently empty.

I agree with you that it's usually better to block than to busy-wait.


  reply	other threads:[~2006-12-06 22:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-06 16:14 Steve Simon
2006-12-06 16:35 ` Richard Bilson
2006-12-06 22:36   ` LiteStar numnums
2006-12-06 22:58     ` Richard Bilson [this message]
2006-12-07  0:07       ` David Leimbach
2006-12-07 21:37 ` 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=676c3c4f0612061458gd767117qb67b4bce8b027e43@mail.gmail.com \
    --to=rcbilson@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).