qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore
Date: Mon, 16 Jul 2012 16:03:20 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

Il 16/07/2012 15:53, Jan Kiszka ha scritto:
>> > 
>> > qemu_cond_wait only uses WaitForSingleObject with INFINITE timeout, and
>> > the algorithm relies on that.
> I see. But this doesn't look complex awfully. Just move the waker
> signaling from within cond_wait under the mutex as well, maybe add
> another flag if there is really someone waiting, and that's it. The
> costs should be hard to measure, even in line of code.

There is still a race after WaitForSingleObject times out.  You need to
catch the mutex before decreasing the number of waiters, and during that
window somebody can broadcast the condition variable.

I'm not saying it's impossible, just that it's hard and I dislike
qemu_cond_timedwait as much as you dislike semaphores. :)

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]