[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore
From: |
Jan Kiszka |
Subject: |
Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore |
Date: |
Mon, 16 Jul 2012 16:09:10 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
On 2012-07-16 16:03, Paolo Bonzini wrote:
> 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.
...and that's why you check what needs to be done to handle this race
after grabbing the mutex. IOW, replicate the state information that the
Windows semaphore contains into the emulated condition variable object.
>
> I'm not saying it's impossible, just that it's hard and I dislike
> qemu_cond_timedwait as much as you dislike semaphores. :)
As you cannot eliminate our use cases for condition variables, let's
focus on the existing synchronization patterns instead of introducing
new ones + new mechanisms.
Jan
--
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux
- [Qemu-devel] [PATCH 06/12] linux-aio: use event notifiers, (continued)
- [Qemu-devel] [PATCH 06/12] linux-aio: use event notifiers, Paolo Bonzini, 2012/07/16
- [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore, Paolo Bonzini, 2012/07/16
- Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore, Jan Kiszka, 2012/07/16
- [Qemu-devel] [PATCH] qemu-thread: Introduce qemu_cond_timedwait for POSIX, Jan Kiszka, 2012/07/16
- Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore, Paolo Bonzini, 2012/07/16
- Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore, Jan Kiszka, 2012/07/16
- Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore, Paolo Bonzini, 2012/07/16
- Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore, Jan Kiszka, 2012/07/16
- Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore, Paolo Bonzini, 2012/07/16
- Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore,
Jan Kiszka <=
- Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore, Paolo Bonzini, 2012/07/16
- Re: [Qemu-devel] [PATCH 07/12] qemu-thread: add QemuSemaphore, Paolo Bonzini, 2012/07/24
[Qemu-devel] [PATCH 08/12] aio: add generic thread-pool facility, Paolo Bonzini, 2012/07/16
[Qemu-devel] [PATCH 10/12] raw: merge posix-aio-compat.c into block/raw-posix.c, Paolo Bonzini, 2012/07/16
[Qemu-devel] [PATCH 11/12] raw-posix: rename raw-posix-aio.h, hide unavailable prototypes, Paolo Bonzini, 2012/07/16
[Qemu-devel] [PATCH 12/12] raw-win32: add emulated AIO support, Paolo Bonzini, 2012/07/16
[Qemu-devel] [PATCH 09/12] block: switch posix-aio-compat to threadpool, Paolo Bonzini, 2012/07/16