qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: qemu-devel@nongnu.org
Cc: Matthew Bloch <matthew@bytemark.co.uk>,
	Paul Brook <paul@codesourcery.com>,
	kvm@vger.kernel.org
Subject: Re: [Qemu-devel] Re: [PATCH] Fix freezing bug in curses console
Date: Mon, 2 Mar 2009 16:57:52 +0000	[thread overview]
Message-ID: <20090302165752.GB26974@shareable.org> (raw)
In-Reply-To: <49AA968B.7000802@codemonkey.ws>

Anthony Liguori wrote:
> >When using the pipe as a simple semaphore all you care about is the 
> >presence or absence of data. It doesn't matter if subsequent writes loose 
> >data (e.g. by not retrying a nonblocking write) as long as a write to an 
> >empty pipe succeeds.
> 
> Yup.  You need to use a global flag to distinguish the type of signal.

If you have a set of BHs which can be scheduled from a signal handler,
set a flag in the BH when it's scheduled, prior to the non-blocking
pipe write.  The select-pipe reader can then look at all eligible BHs
looking for ones with the flag set.

If you can enqueue them in the signal handler that's even better, but
obviously beware of race conditions.

Don't forget to completely drain the pipe when reading.

Maybe use an eventfd instead of a pipe if you have eventfd. :-)

If the signal handler might be run in different threads, you'll need
to take care of memory ordering.  The flag must be set before writing
to the pipe, as observed by the pipe-reading thread.

-- Jamie

      reply	other threads:[~2009-03-02 16:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-21 15:51 [Qemu-devel] [PATCH] Fix freezing bug in curses console Matthew Bloch
2009-02-27 19:49 ` [Qemu-devel] " Anthony Liguori
2009-02-27 21:01   ` andrzej zaborowski
2009-02-27 21:04     ` Anthony Liguori
2009-02-28 21:21       ` Jamie Lokier
2009-03-01 11:36         ` Daniel P. Berrange
2009-03-01 13:03           ` Paul Brook
2009-03-01 14:07             ` Anthony Liguori
2009-03-02 16:57               ` Jamie Lokier [this message]

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=20090302165752.GB26974@shareable.org \
    --to=jamie@shareable.org \
    --cc=kvm@vger.kernel.org \
    --cc=matthew@bytemark.co.uk \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /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).