From: Fam Zheng <famz@redhat.com>
To: Liviu Ionescu <ilg@livius.net>
Cc: QEMU Developer <Qemu-devel@nongnu.org>,
"Daniel P. Berrange" <berrange@redhat.com>
Subject: Re: [Qemu-devel] experience with SDL2, event loop & main thread
Date: Tue, 13 Dec 2016 15:04:53 +0800 [thread overview]
Message-ID: <20161213070453.GB2165@lemon> (raw)
In-Reply-To: <F71562E4-2D12-4F28-AC3F-70463E91E6A5@livius.net>
On Mon, 12/12 17:07, Liviu Ionescu wrote:
>
> > On 12 Dec 2016, at 16:51, Fam Zheng <famz@redhat.com> wrote:
> >
> > On Mon, 12/12 15:22, Liviu Ionescu wrote:
> >> so, back to square one; any suggestion on how to avoid the periodic timer
> >> required to poll SDL system events?
> >
> > Good question, I've missed that!
> >
> > Sadly I don't find it possible. The main thread of QEMU has to run the glib
> > event loop so it cannot block on SDL_WaitEvent().
>
> why should the glib event loop run as the main thread? according to my tests,
> on linux and macos the glib event loop can run very well on a regular thread.
According to the API documentation I think it is supposed to work, but it will
be an unusual use case anyway so it's presumably less tested and I remember
hearing about things break here and there (cannot recall any detail :().
>
> the problem that I encountered with this approach was on windows, where there
> is no `poll()`, and the existing implementation of it in qemu does not work if
> moved on a different thread. I do not know if the qemu implementation is not
> correct, or the win32 api does not allow this.
>
> > ... it cannot block on SDL_WaitEvent().
>
> initially I considered that rearranging threads to free the main thread for a
> dedicated SDL loop that blocks on SDL_WaitEvent() is a good solution, but then
> I took a look at how SDL_WaitEvent() is implemented: a loop that sleeps 10 ms
> and checks if there are events in the queue. :-(
>
> so the best solution would be to make SDL asynchronous and run it on the glib
> event loop.
Maybe, but that would be a big project.
Given how SDL_WaitEvent() works as you said above, the easies solution would be
using qemu_bh_schedule_idle in the QEMU main loop and poll event there
periodically.
Fam
next prev parent reply other threads:[~2016-12-13 7:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-10 16:16 [Qemu-devel] experience with SDL2, event loop & main thread Liviu Ionescu
2016-12-12 3:35 ` Fam Zheng
2016-12-12 7:18 ` Liviu Ionescu
2016-12-12 7:39 ` Fam Zheng
2016-12-12 7:43 ` Liviu Ionescu
2016-12-12 9:39 ` Fam Zheng
2016-12-12 10:20 ` Liviu Ionescu
2016-12-12 10:36 ` Fam Zheng
2016-12-12 10:42 ` Daniel P. Berrange
2016-12-12 11:27 ` Liviu Ionescu
2016-12-12 12:28 ` Fam Zheng
2016-12-12 13:22 ` Liviu Ionescu
2016-12-12 14:51 ` Fam Zheng
2016-12-12 15:07 ` Liviu Ionescu
2016-12-13 7:04 ` Fam Zheng [this message]
2016-12-13 7:21 ` Liviu Ionescu
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=20161213070453.GB2165@lemon \
--to=famz@redhat.com \
--cc=Qemu-devel@nongnu.org \
--cc=berrange@redhat.com \
--cc=ilg@livius.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).